@pdfbutler/migration-cli 0.0.10 → 0.0.12

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/README.md CHANGED
@@ -2,13 +2,21 @@
2
2
 
3
3
  [![NPM](https://img.shields.io/npm/v/pdfbutler-migration-cli.svg?label=pdfbutler-migration-cli)](https://www.npmjs.com/package/@pdfbutler/migration-cli) [![Downloads/week](https://img.shields.io/npm/dw/pdfbutler-migration-cli.svg)](https://www.npmjs.com/package/@pdfbutler/migration-cli) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/pdfbutler-migration-cli/main/LICENSE.txt)
4
4
 
5
+ ## Warning
6
+
7
+ v0.0.11 updates: <br/>
8
+
9
+ - '-b' flag disables backend export. If specified, the export operation doesn't use a PDF Butler backend process for exporting the configuration. By default, backend export is enabled.
10
+ - New '-l --logs' flag. Use this flag to enable a more detailed log of the migration process.
11
+ - New '-p --partial' flag. Use this flag to ignore invalid document configurations and allow the export of document configuration files with the backend part.
12
+
5
13
  ## About
6
14
 
7
15
  @pdfbutler/migration-cli is a Salesforce plugin designed to simplify and automate the process of migrating configurations within the PDF Butler system in the Salesforce environment. PDF Butler is a powerful tool for generating and automating documents in the Salesforce platform, and the use of this CLI plugin allows users to easily manage configurations and transfer them between different Salesforce instances or projects.
8
16
 
9
17
  ### Main features of the plugin:
10
18
 
11
- Export and import configurations: The plugin enables easy export and import of PDF Butler configurations. This is particularly useful for moving settings between different Salesforce environments or projects, ensuring consistency and ease of management.
19
+ Export and import configurations: The plugin enables bulk export and import of PDF Butler configurations. This is particularly useful for moving settings between different Salesforce environments or projects, ensuring consistency and ease of management.
12
20
  Migration customization: The plugin provides users with the ability to customize the migration process using various flags and parameters to meet individual needs. With this plugin, you can specify the target Salesforce account, use environment variables for authentication, define custom URLs for import or export, and other parameters of your choice.
13
21
 
14
22
  ## Installation
@@ -66,7 +74,7 @@ Export PDF Butler configurations.
66
74
 
67
75
  ```
68
76
  USAGE
69
- $ sf butler pb export [--target | -t <value>] [--id | -i <value>] [--out | -o <value>] [--stage | -s <value>] [--backend | -b] [--auth-env-var | -a <value>] [--endpoint | -e <value>] [--unzip | -u]
77
+ $ sf butler pb export [--target | -t <value>] [--id | -i <value>] [--out | -o <value>] [--stage | -s <value>] [--auth-env-var | -a <value>] [--endpoint | -e <value>] [--backend | -b] [--unzip | -u] [-l | --logs] [-p | --partial]
70
78
 
71
79
  FLAGS
72
80
  -t, --target=<value> The Salesforce org username credentials to connect to the target org. (Required)
@@ -78,6 +86,8 @@ FLAGS
78
86
 
79
87
  -u, --unzip Use this flag to unzip the exported configuration. (Optional)
80
88
  -b, --backend Use this flag to disable PDF Butler backend export. (Optional)
89
+ -l, --logs Use it to get a more detailed log of migration process. (Optional)
90
+ -p, --partial Use this flag to ignore invalid document configurations and allow the export of document configuration files with the backend part.
81
91
 
82
92
  DESCRIPTION
83
93
  Export DocConfigs and related DataSource files from your organization.
@@ -89,29 +99,41 @@ DESCRIPTION
89
99
 
90
100
  To initiate an export, ensure you specify the necessary parameters, including the target org, PDF Butler docuemnt configuration ID,
91
101
  output path, define PDF Butler credentials for backend authentication, specify endpoints and stage.
92
- Additionally, you have the flexibility to enable or disable backend exports and even choose to unzip the exported configuration.
102
+ Additionally, you have the flexibility to enable or disable backend exports, ignore invalid document configurations and allow the export of document configuration files with the backend part, get a more detailed log of migration process and even choose to unzip the exported configuration.
93
103
 
94
104
  EXAMPLES
95
- Run with --unzip and --backend flags
105
+ Run with --backend flag only
96
106
 
97
107
  $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
98
108
  -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
99
- -a 'pdf_butler_user_name-ADMIN:admin_password' -b -u
109
+ -a 'pdf_butler_user_name-ADMIN:admin_password' -b
110
+
111
+ # Console output:
112
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
100
113
 
101
114
  # Created:
102
115
  Directory 'sfdc/export_folder_name'{
103
- file 'docconfig.json'
116
+ file 'docconfig_id.json'
104
117
  }
105
118
 
106
- Run with --backend flag only
119
+ Run without --backend flag
107
120
 
108
121
  $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
109
122
  -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
110
- -a 'pdf_butler_user_name-ADMIN:admin_password' -b
123
+ -a 'pdf_butler_user_name-ADMIN:admin_password'
124
+
125
+ # Console output:
126
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
111
127
 
112
128
  # Created:
113
129
  Directory 'sfdc/export_folder_name'{
114
- file 'docconfig.json'
130
+ file 'docconfig_id.json',
131
+ zip file'docconfig_id.zip'{
132
+ Directory 'ConfigTypes',
133
+ Directory 'DataSources',
134
+ file 'doc-config.json',
135
+ file 'TemplateName.docx'
136
+ }
115
137
  }
116
138
 
117
139
  Run with --unzip flag only
@@ -120,10 +142,166 @@ EXAMPLES
120
142
  -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
121
143
  -a 'pdf_butler_user_name-ADMIN:admin_password' -u
122
144
 
145
+ # Console output:
146
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
147
+
148
+ # Created:
149
+ Directory 'sfdc/export_folder_name'{
150
+ file 'docconfig_id.json',
151
+ Unziped directory 'docconfig_id'{
152
+ Directory 'ConfigTypes',
153
+ Directory 'DataSources',
154
+ file 'doc-config.json',
155
+ file 'TemplateName.docx'
156
+ }
157
+ }
158
+
159
+ Run without --unzip flag
160
+
161
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
162
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
163
+ -a 'pdf_butler_user_name-ADMIN:admin_password'
164
+
165
+ # Console output:
166
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
167
+
168
+ # Created:
169
+ Directory 'sfdc/export_folder_name'{
170
+ file 'docconfig_id.json',
171
+ zip file'docconfig_id.zip'{
172
+ Directory 'ConfigTypes',
173
+ Directory 'DataSources',
174
+ file 'doc-config.json',
175
+ file 'TemplateName.docx'
176
+ }
177
+ }
178
+
179
+ Run with --logs flag only
180
+
181
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
182
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
183
+ -a 'pdf_butler_user_name-ADMIN:admin_password' -l
184
+
185
+ # Console output:
186
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
187
+ DocConfig exported - 10061
188
+ Exported data from backend - 71940
189
+ Exported data from backend has been archived
190
+ User has read/write permissions
191
+ Archive unzipped and recorded locally
192
+
193
+ # Created:
194
+ Directory 'sfdc/export_folder_name'{
195
+ file 'docconfig_id.json',
196
+ zip file'docconfig_id.zip'{
197
+ Directory 'ConfigTypes',
198
+ Directory 'DataSources',
199
+ file 'doc-config.json',
200
+ file 'TemplateName.docx'
201
+ }
202
+ }
203
+
204
+ Run without --logs flag
205
+
206
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
207
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
208
+ -a 'pdf_butler_user_name-ADMIN:admin_password'
209
+
210
+ # Console output:
211
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
212
+
123
213
  # Created:
124
214
  Directory 'sfdc/export_folder_name'{
125
- file 'docconfig.json',
126
- Unziped directory 'archive_name'{
215
+ file 'docconfig_id.json',
216
+ zip file'docconfig_id.zip'{
217
+ Directory 'ConfigTypes',
218
+ Directory 'DataSources',
219
+ file 'doc-config.json',
220
+ file 'TemplateName.docx'
221
+ }
222
+ }
223
+
224
+ Run with --partial flag only and docconfig with backend part
225
+
226
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
227
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
228
+ -a 'pdf_butler_user_name-ADMIN:admin_password' -p
229
+
230
+ # Console output:
231
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
232
+
233
+ # Created:
234
+ Directory 'sfdc/export_folder_name'{
235
+ file 'docconfig_id.json',
236
+ zip file'docconfig_id.zip'{
237
+ Directory 'ConfigTypes',
238
+ Directory 'DataSources',
239
+ file 'doc-config.json',
240
+ file 'TemplateName.docx'
241
+ }
242
+ }
243
+
244
+ Run with --partial flag only and docconfig without backend part
245
+
246
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id_1, document_configuration_id_2'
247
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
248
+ -a 'pdf_butler_user_name-ADMIN:admin_password' -p
249
+
250
+ # Console output:
251
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
252
+
253
+ # Created:
254
+ Directory 'sfdc/export_folder_name'{
255
+ file 'docconfig_id.json',
256
+ zip file'docconfig_id.zip'{
257
+ Directory 'ConfigTypes',
258
+ Directory 'DataSources',
259
+ file 'doc-config.json',
260
+ file 'TemplateName.docx'
261
+ }
262
+ }
263
+
264
+ Run without --partial flag and docconfig without backend part
265
+
266
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id_1, document_configuration_id_2'
267
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
268
+ -a 'pdf_butler_user_name-ADMIN:admin_password'
269
+
270
+ # Console output:
271
+ Error (1): One or more docConfigs have no backend.
272
+
273
+ Run with --backend flag and other optional flags
274
+
275
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
276
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
277
+ -a 'pdf_butler_user_name-ADMIN:admin_password' -b [-u | -l | -p]
278
+
279
+ # Console output:
280
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
281
+
282
+ # Created:
283
+ Directory 'sfdc/export_folder_name'{
284
+ file 'docconfig_id.json'
285
+ }
286
+
287
+ Run with --unzip and --logs flags
288
+
289
+ $ sf butler pb export -t sfusername@sandbox.com -i 'document_configuration_id'
290
+ -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
291
+ -a 'pdf_butler_user_name-ADMIN:admin_password' -u -l
292
+
293
+ # Console output:
294
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
295
+ DocConfig exported - 10061
296
+ Exported data from backend - 71940
297
+ Exported data from backend has been archived
298
+ User has read/write permissions
299
+ Archive unzipped and recorded locally
300
+
301
+ # Created:
302
+ Directory 'sfdc/export_folder_name'{
303
+ file 'docconfig_id.json',
304
+ Unziped directory 'docconfig_id'{
127
305
  Directory 'ConfigTypes',
128
306
  Directory 'DataSources',
129
307
  file 'doc-config.json',
@@ -137,10 +315,13 @@ EXAMPLES
137
315
  -o 'export_folder_name/archive_or_folder_name' -s 'TEST' -e 'https://www.pdfbutler.com'
138
316
  -a 'pdf_butler_user_name-ADMIN:admin_password'
139
317
 
318
+ # Console output:
319
+ Connected to sfusername@sandbox.com (00D06000001aXGkEAM) with API version 58.0
320
+
140
321
  # Created:
141
322
  Directory 'sfdc/export_folder_name'{
142
- file 'docconfig.json',
143
- zip file'archive_name.zip'{
323
+ file 'docconfig_id.json',
324
+ zip file'docconfig_id.zip'{
144
325
  Directory 'ConfigTypes',
145
326
  Directory 'DataSources',
146
327
  file 'doc-config.json',
@@ -182,6 +363,12 @@ FLAG DESCRIPTIONS
182
363
  -u, --unzip
183
364
  Use this flag to indicate that the exported configuration should be unzipped.
184
365
  If specified, the exported configuration will be unzipped after the export process is complete.
366
+
367
+ -l, --logs
368
+ Use this flag to get a more detailed log of migration process.
369
+
370
+ -p, --partial
371
+ Use this flag to ignore invalid document configurations and allow the export of document configuration files with the backend part.
185
372
  ```
186
373
 
187
374
  ## butler pb import
@@ -197,7 +384,8 @@ FLAGS
197
384
  -a, --auth-env-var=<value> The PDF Butler credentials for backend authentication. (Required)
198
385
  -e, --endpoint=<value> The URL PDF Butler endpoint for import. (Required)
199
386
  -s, --stage=<value> The CADMUS stage. (Required)
200
- -f, --config=<value> The path to the configuration file or directory containing configurations to import. (Required)
387
+ -f, --config=<value> The path to the directory containing configurations to import. (Required)
388
+ -l, --logs Use it to get a more detailed log of migration process. (Optional)
201
389
 
202
390
  DESCRIPTION
203
391
  Import DocConfigs and related DataSource files into your organization.
@@ -235,4 +423,140 @@ FLAG DESCRIPTIONS
235
423
  -f, --config <value>
236
424
  Specifies the path to the configuration file or directory containing configurations to import.
237
425
  This flag is required to determine which configurations to import.
426
+
427
+ -l, --logs
428
+ Use this flag to get a more detailed log of migration process.
429
+ ```
430
+
431
+ ## Typical errors and solutions
432
+
433
+ Typical errors that may occur when using the plugin and their solutions.
434
+
435
+ ### Export
436
+
437
+ - EPERM operation not permitted, chmod 'path_to_directory_to_export'.
438
+
439
+ ```
440
+ SOLUTION: error typically occurs due to insufficient permissions. To resolve it, make sure you have the necessary permissions to write to the specified directory. You can use the chmod command to change the directory permissions.
441
+
442
+ ```
443
+
444
+ - Error (1): Flag --target expects a value.
445
+
446
+ ```
447
+ SOLUTION: When using the --target flag, make sure to provide a valid Salesforce org username after the flag.
448
+
449
+ ```
450
+
451
+ - Error (1): No authorization information found for sfusername@sandbox.com.
452
+
453
+ ```
454
+ SOLUTION: Ensure that you have provided the correct Salesforce username. Double-check your credentials and ensure that they are properly configured in the plugin.
455
+
456
+ ```
457
+
458
+ - Error (1): Flag --id expects a value.
459
+
460
+ ```
461
+ SOLUTION: When using the --id flag, make sure to provide a valid value after the flag. It should specify the ID or identifiers required for the export.
462
+
463
+ ```
464
+
465
+ - Error (1): No matching Doc Configs ids found.
466
+
467
+ ```
468
+ SOLUTION: Verify that the Doc Config IDs you provided are correct and exist in the system.
469
+
470
+ ```
471
+
472
+ - Error (1): One or more docConfigs have no backend.
473
+
474
+ ```
475
+ SOLUTION: This error indicates that some document configurations are missing backend part. Review the document configurations and ensure that they are properly configured with the required server modules. Or you can add the "-p --partial" flag to enable exporting those docconfigs that have a backend part.
476
+
477
+ ```
478
+
479
+ - Error (1): Flag --out expects a value.
480
+
481
+ ```
482
+ SOLUTION: When using the --out flag, ensure that you specify a valid directory path where the output should be saved.
483
+
484
+ ```
485
+
486
+ - Error (1): Flag --stage expects a value.
487
+
488
+ ```
489
+ SOLUTION: When using the --stage flag, make sure to provide a valid CADMUS stage.
490
+
491
+ ```
492
+
493
+ - Error (1): Flag --auth-env-var expects a value.
494
+
495
+ ```
496
+ SOLUTION: When using the --auth-env-var flag, provide the PDF Butler credentials for backend authentication. Ensure that the PDF Butler credentials is correctly set and contains the required credentials (Username and Admin password).
497
+
498
+ ```
499
+
500
+ - Error (1): Flag --endpoint expects a value.
501
+
502
+ ```
503
+ SOLUTION: When using the --endpoint flag, specify the correct endpoint URL as the value.
504
+
505
+ ```
506
+
507
+ - Error (1): Response code 401 (Unauthorized).
508
+
509
+ ```
510
+ SOLUTION: This error indicates that your request lacks proper authentication. Double-check your credentials like PDF Butler Username or PDF Butler Admin password. Correct example: 'Username-ADMIN:Admin_password'
511
+
512
+ ```
513
+
514
+ - Error (1): System.LicenseException: The Apex Class RestImportDocConfig is part of the AppExchange Package PDF Butler, and requires a license to use.
515
+
516
+ ```
517
+ SOLUTION: To resolve this error, you need to acquire the required license for the AppExchange Package PDF Butler to use the plugin command. Contact your Salesforce administrator or license provider to obtain the necessary license.
518
+
519
+ ```
520
+
521
+ ### Import
522
+
523
+ - Error (1): Flag --target expects a value.
524
+
525
+ ```
526
+ SOLUTION: When using the --target flag, make sure to provide a valid Salesforce org username after the flag.
527
+ ```
528
+
529
+ - Error (1): Flag --auth-env-var expects a value.
530
+
531
+ ```
532
+ SOLUTION:
533
+
534
+ ```
535
+
536
+ - Error (1): Flag --auth-env-var expects a value.
537
+
538
+ ```
539
+ SOLUTION: When using the --auth-env-var flag, provide the PDF Butler credentials for backend authentication. Ensure that the PDF Butler credentials is correctly set and contains the required credentials (Username and Admin password).
540
+
541
+ ```
542
+
543
+ - Error (1): Flag --endpoint expects a value.
544
+
545
+ ```
546
+ SOLUTION: When using the --endpoint flag, specify the correct endpoint URL as the value.
547
+
548
+ ```
549
+
550
+ - Error (1): Flag --stage expects a value.
551
+
552
+ ```
553
+ SOLUTION: When using the --stage flag, make sure to provide a valid CADMUS stage.
554
+
555
+ ```
556
+
557
+ - Error (1): Flag --config expects a value.
558
+
559
+ ```
560
+ SOLUTION: When using the --config flag, ensure that you specify a valid directory path to docconfigs.
561
+
238
562
  ```
@@ -18,6 +18,10 @@ export default class ButlerPbExport extends SfCommand<Buffer> {
18
18
  endpoint: import("@oclif/core/lib/interfaces").OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
19
19
  stage: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
20
20
  unzip: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
21
+ logs: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
22
+ partial: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
21
23
  };
24
+ private static getDocConfigIds;
25
+ private static getDocConfigs;
22
26
  run(): Promise<Buffer>;
23
27
  }
@@ -1,5 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable @typescript-eslint/no-misused-promises */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
5
+ /* eslint-disable @typescript-eslint/restrict-template-expressions */
6
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
7
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
8
+ /* eslint-disable sf-plugin/no-missing-messages */
9
+ /* eslint-disable @typescript-eslint/prefer-for-of */
10
+ /* eslint-disable no-await-in-loop */
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
+ /* eslint-disable no-console */
3
13
  const fs_1 = require("fs");
4
14
  const path = require("path");
5
15
  const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
@@ -7,18 +17,59 @@ const core_1 = require("@salesforce/core");
7
17
  const AdmZip = require("adm-zip");
8
18
  const got_1 = require("got");
9
19
  core_1.Messages.importMessagesDirectory(__dirname);
10
- // const messages = Messages.loadMessages('pdfbutler-migration-cli', 'butler.pb.export');
11
20
  const messages = core_1.Messages.loadMessages('@pdfbutler/migration-cli', 'butler.pb.export');
12
21
  class ButlerPbExport extends sf_plugins_core_1.SfCommand {
22
+ static getDocConfigIds(id) {
23
+ const docConfigIds = id.split(/([\w-]{36})/).filter((n) => n);
24
+ docConfigIds.forEach((docId) => {
25
+ if (!docId.trim()) {
26
+ docConfigIds.splice(docConfigIds.indexOf(docId), 1);
27
+ }
28
+ });
29
+ if (docConfigIds.length <= 0) {
30
+ throw new Error('No matching Doc Configs ids found');
31
+ }
32
+ return docConfigIds;
33
+ }
34
+ static async getDocConfigs(docConfigIds, username) {
35
+ let docConfigPromises;
36
+ let connection;
37
+ let authInfo;
38
+ try {
39
+ authInfo = await core_1.AuthInfo.create({ username });
40
+ connection = await core_1.Connection.create({ authInfo });
41
+ }
42
+ catch (e) {
43
+ throw new Error('Connection to Salesforce has been failed');
44
+ }
45
+ console.log(`Connected to ${username} (${authInfo.getFields().orgId}) with API version ${connection.version}`);
46
+ try {
47
+ docConfigPromises = docConfigIds.map(async (docConfigId) => {
48
+ const promise = await connection.apex.get(`/cadmus_core/DocConfig/Export2/${docConfigId}`);
49
+ return promise;
50
+ });
51
+ }
52
+ catch (e) {
53
+ throw new Error('DocConfig export has been failed');
54
+ }
55
+ return Promise.all(docConfigPromises);
56
+ }
13
57
  async run() {
14
58
  const { flags } = await this.parse(ButlerPbExport);
15
59
  const outFile = flags.out;
16
60
  const outDir = path.dirname(outFile);
17
- const authInfo = await core_1.AuthInfo.create({ username: flags.target });
18
- const connection = await core_1.Connection.create({ authInfo });
19
- this.log(`Connected to ${flags.target} (${authInfo.getFields().orgId}) with API version ${connection.version}`);
20
- const docConfigResponse = await connection.apex.get(`/cadmus_core/DocConfig/Export2/${flags.id}`);
21
- let zip;
61
+ let docConfigIds = [];
62
+ let docConfigResponses = [];
63
+ try {
64
+ docConfigIds = ButlerPbExport.getDocConfigIds(flags.id);
65
+ docConfigResponses = await ButlerPbExport.getDocConfigs(docConfigIds, flags.target);
66
+ if (flags.logs)
67
+ this.log(`DocConfig exported - ${JSON.stringify(docConfigResponses).length}`);
68
+ }
69
+ catch (e) {
70
+ throw new Error('No matching Doc Configs ids found');
71
+ }
72
+ let zipMap = new Map();
22
73
  let result = Buffer.from('');
23
74
  if (!flags.backend) {
24
75
  const auth = flags['auth-env-var'];
@@ -26,33 +77,75 @@ class ButlerPbExport extends sf_plugins_core_1.SfCommand {
26
77
  if (auth?.indexOf(':')) {
27
78
  base64Auth = Buffer.from(auth).toString('base64');
28
79
  }
29
- const finalUrl = `${flags.endpoint?.toString()}config/export-config/${flags.stage}/${flags.id}`;
30
- result = await (0, got_1.default)(finalUrl, {
31
- headers: {
32
- Authorization: `Basic ${base64Auth}`,
33
- },
34
- }).buffer();
35
- zip = new AdmZip(result);
80
+ for (const docConfigId of docConfigIds) {
81
+ const finalUrl = `${flags.endpoint?.toString()}config/export-config/${flags.stage}/${docConfigId}`;
82
+ try {
83
+ result = await (0, got_1.default)(finalUrl, {
84
+ headers: {
85
+ Authorization: `Basic ${base64Auth}`,
86
+ },
87
+ }).buffer();
88
+ if (flags.logs)
89
+ this.log(`Exported data from backend - ${result.length}`);
90
+ zipMap.set(docConfigId, new AdmZip(result));
91
+ if (flags.logs)
92
+ this.log('Exported data from backend has been archived');
93
+ }
94
+ catch (err) {
95
+ if (!flags.partial) {
96
+ this.error(`${err}. One or more docConfigs have no backend.`);
97
+ }
98
+ }
99
+ }
36
100
  }
37
101
  else {
38
- zip = new AdmZip();
102
+ zipMap = new Map();
39
103
  }
40
104
  await fs_1.promises.mkdir(`./sfdc/${outDir}`, { recursive: true });
41
- if (flags.unzip) {
42
- zip.extractAllTo(`./sfdc/${outFile}`, false);
43
- await fs_1.promises.writeFile(`./sfdc/${outDir}/docconfig.json`, JSON.stringify(docConfigResponse));
105
+ if (flags.logs) {
106
+ try {
107
+ await fs_1.promises.access(`./sfdc/${outDir}`, fs_1.promises.constants.R_OK | fs_1.promises.constants.W_OK);
108
+ this.log('User has read/write permissions');
109
+ }
110
+ catch (err) {
111
+ this.log('User doesn\'t have read/write permissions');
112
+ }
44
113
  }
45
- else {
46
- let zipToExport = new AdmZip();
47
- if (result) {
48
- zipToExport = new AdmZip();
114
+ if (zipMap.size > 0) {
115
+ if (flags.unzip) {
116
+ const extractionAndWritePromises = Array.from(zipMap.entries()).map(async ([key, value]) => {
117
+ value.extractAllTo(`./sfdc/${outDir}/${key}`, false);
118
+ const filePath = `./sfdc/${outDir}/${key}.json`;
119
+ const data = JSON.stringify(docConfigResponses[docConfigIds.indexOf(key)]);
120
+ await fs_1.promises.writeFile(filePath, data);
121
+ });
122
+ await Promise.all(extractionAndWritePromises);
123
+ if (flags.logs)
124
+ this.log('Archive unzipped and recorded locally');
49
125
  }
50
- for (const entry of zip.getEntries()) {
51
- zipToExport.addFile(entry.entryName, zip.readFile(entry));
126
+ else {
127
+ const zipAndWritePromises = Array.from(zipMap.entries()).map(async ([key, value]) => {
128
+ const zipToExport = new AdmZip();
129
+ for (const entry of value.getEntries()) {
130
+ zipToExport.addFile(entry.entryName, value.readFile(entry));
131
+ }
132
+ zipToExport.addFile('sfdc/docconfig.json', Buffer.from(JSON.stringify(docConfigResponses[docConfigIds.indexOf(key)])));
133
+ const zipPromise = fs_1.promises.writeFile(`./sfdc/${outDir}/${key}.zip`, zipToExport.toBuffer());
134
+ const jsonPromise = fs_1.promises.writeFile(`./sfdc/${outDir}/${key}.json`, JSON.stringify(docConfigResponses[docConfigIds.indexOf(key)]));
135
+ await Promise.all([zipPromise, jsonPromise]);
136
+ });
137
+ await Promise.all(zipAndWritePromises);
52
138
  }
53
- zipToExport.addFile('sfdc/docconfig.json', docConfigResponse);
54
- await fs_1.promises.writeFile(`./sfdc/${outFile}.zip`, zipToExport.toBuffer());
55
- await fs_1.promises.writeFile(`./sfdc/${outDir}/docconfig.json`, JSON.stringify(docConfigResponse));
139
+ }
140
+ else {
141
+ const writePromises = docConfigIds.map(async (docConfigId) => {
142
+ const filePath = `./sfdc/${outDir}/${docConfigId}.json`;
143
+ const data = JSON.stringify(docConfigResponses[docConfigIds.indexOf(docConfigId)]);
144
+ await fs_1.promises.writeFile(filePath, data);
145
+ });
146
+ await Promise.all(writePromises);
147
+ if (flags.logs)
148
+ this.log('Archive recorded locally');
56
149
  }
57
150
  return result;
58
151
  }
@@ -79,6 +172,7 @@ ButlerPbExport.flags = {
79
172
  }),
80
173
  out: sf_plugins_core_1.Flags.string({
81
174
  summary: messages.getMessage('flags.out.summary'),
175
+ // eslint-disable-next-line sf-plugin/dash-o
82
176
  char: 'o',
83
177
  required: true,
84
178
  }),
@@ -103,6 +197,14 @@ ButlerPbExport.flags = {
103
197
  summary: messages.getMessage('flags.unzip.summary'),
104
198
  char: 'u',
105
199
  }),
200
+ logs: sf_plugins_core_1.Flags.boolean({
201
+ summary: messages.getMessage('flags.logs.summary'),
202
+ char: 'l',
203
+ }),
204
+ partial: sf_plugins_core_1.Flags.boolean({
205
+ summary: messages.getMessage('flags.partial.summary'),
206
+ char: 'p',
207
+ }),
106
208
  };
107
209
  exports.default = ButlerPbExport;
108
210
  //# sourceMappingURL=export.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"export.js","sourceRoot":"","sources":["../../../../src/commands/butler/pb/export.ts"],"names":[],"mappings":";;AAAA,2BAAoC;AACpC,6BAA8B;AAC9B,iEAA+D;AAC/D,2CAAkE;AAClE,kCAAmC;AACnC,6BAAsB;AAEtB,eAAQ,CAAC,uBAAuB,CAA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,KAAK,EAAE,uBAAK,CAAC,OAAO,CAAC;QACnB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC;QACnD,IAAI,EAAE,GAAG;KACV,CAAC;IACF,IAAI,EAAE,uBAAK,CAAC,OAAO,CAAC;QAClB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAClD,IAAI,EAAE,GAAG;KACV,CAAC;IACF,OAAO,EAAE,uBAAK,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;QACrD,IAAI,EAAE,GAAG;KACV,CAAC;CACH,CAAC;kBAzDiB,cAAc"}
@@ -14,6 +14,7 @@ export default class ButlerPbImport extends SfCommand<ButlerPbImportResult> {
14
14
  endpoint: import("@oclif/core/lib/interfaces").OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
15
15
  stage: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
16
16
  config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
+ logs: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
18
  };
18
19
  private static getTargetPath;
19
20
  run(): Promise<ButlerPbImportResult>;
@@ -29,40 +29,41 @@ class ButlerPbImport extends sf_plugins_core_1.SfCommand {
29
29
  }
30
30
  async run() {
31
31
  const { flags } = await this.parse(ButlerPbImport);
32
- const statInfo = await new Promise((resolve) => {
33
- fs.stat(flags.config, (_, stat) => {
34
- resolve(stat);
35
- });
36
- });
37
- let zip = null;
38
- if (statInfo?.isDirectory()) {
39
- zip = new AdmZip();
40
- zip.addLocalFolder(flags.config);
32
+ const zipArray = [];
33
+ const jsonArray = [];
34
+ const files = fs.readdirSync(`${flags.config}`);
35
+ await Promise.all(files.map((fileName) => {
36
+ const fullPath = path.join(flags.config, fileName);
37
+ if (fileName.endsWith('.json')) {
38
+ jsonArray.push(fullPath);
39
+ }
40
+ else {
41
+ zipArray.push(fullPath);
42
+ }
43
+ }));
44
+ const authInfo = await core_1.AuthInfo.create({ username: flags.target });
45
+ const connection = await core_1.Connection.create({ authInfo });
46
+ this.log(`Connected to ${flags.target} (${authInfo.getFields().orgId}) with API version ${connection.version}`);
47
+ try {
48
+ if (jsonArray.length > 0) {
49
+ const promises = jsonArray.map(async (jsonFile) => {
50
+ const sfdcConfig = JSON.parse(await fs.promises.readFile(jsonFile, 'utf8'));
51
+ await connection.apex.post('/cadmus_core/DocConfig/Import', sfdcConfig, {
52
+ headers: { 'content-type': 'application/json' },
53
+ });
54
+ });
55
+ await Promise.all(promises);
56
+ if (flags.logs)
57
+ this.log('Data successfully written to the target Salesforce org');
58
+ }
41
59
  }
42
- if (statInfo?.isFile()) {
43
- zip = new AdmZip(flags.config);
60
+ catch (e) {
61
+ throw new Error('Failed to write data to the target Salesforce org');
44
62
  }
45
- if (zip == null && flags.endpoint) {
63
+ if (zipArray.length === 0 || !flags.endpoint) {
46
64
  return { success: false };
47
65
  }
48
- const targetDir = path.dirname(flags.config);
49
- const authInfo = await core_1.AuthInfo.create({ username: flags.target });
50
- const connection = await core_1.Connection.create({ authInfo });
51
- this.log(`Connected to ${flags.target} (${authInfo.getFields().orgId}) with API version ${connection.version}`);
52
- const sfdcConfig = JSON.parse(fs.readFileSync(`${targetDir}/docconfig.json`)?.toString());
53
- const sfdcConfigObject = new Object();
54
- Object.assign(sfdcConfigObject, sfdcConfig);
55
- await connection.apex.post('/cadmus_core/DocConfig/Import', sfdcConfigObject, { header: { 'content-type': 'application/json' } });
56
66
  if (flags.endpoint) {
57
- if (zip == null) {
58
- return { success: false };
59
- }
60
- const zipToSend = new AdmZip();
61
- for (const entry of zip.getEntries()) {
62
- if (entry != null) {
63
- zipToSend.addFile(entry.entryName, zip.readFile(entry));
64
- }
65
- }
66
67
  if (!flags['auth-env-var']) {
67
68
  this.error('auth-env-var parameter is required when endpoint is provided');
68
69
  return { success: false };
@@ -73,23 +74,50 @@ class ButlerPbImport extends sf_plugins_core_1.SfCommand {
73
74
  base64Auth = Buffer.from(auth).toString('base64');
74
75
  }
75
76
  const baseUrl = `${flags.endpoint.toString()}`;
76
- const txt = zip.readAsText('doc-config.json');
77
- const recordType = JSON.parse(txt).recordType;
78
- const targetPath = ButlerPbImport.getTargetPath(recordType);
79
- const finalUrl = `${baseUrl}${targetPath}`;
80
- const fd = new FormData();
81
- fd.append('zip', zipToSend.toBuffer(), { filename: 'zip' });
82
- fd.append('metadata', JSON.stringify({
83
- stage: flags.stage,
84
- version: 'v10.0',
85
- }), { contentType: 'application/json' });
86
- const resp = await got_1.default.post(finalUrl, {
87
- body: fd.getBuffer(),
88
- headers: fd.getHeaders({
89
- Authorization: `Basic ${base64Auth}`
90
- }),
77
+ if (flags.logs)
78
+ this.log(`Endpoint base URL - ${baseUrl}`);
79
+ zipArray.map(async (zipName) => {
80
+ let zip = new AdmZip();
81
+ if (zipName.endsWith('zip')) {
82
+ zip = new AdmZip(zipName);
83
+ }
84
+ else {
85
+ zip.addLocalFolder(zipName);
86
+ }
87
+ const zipToSend = new AdmZip();
88
+ for (const entry of zip.getEntries()) {
89
+ if (entry != null) {
90
+ zipToSend.addFile(entry.entryName, zip.readFile(entry));
91
+ }
92
+ }
93
+ const txt = zip.readAsText('doc-config.json');
94
+ if (flags.logs)
95
+ this.log(`doc-config.json length - ${txt.length}`);
96
+ const recordType = JSON.parse(txt).recordType;
97
+ const targetPath = ButlerPbImport.getTargetPath(recordType);
98
+ const finalUrl = `${baseUrl}${targetPath}`;
99
+ if (flags.logs)
100
+ this.log(`Final URL - ${finalUrl}`);
101
+ const fd = new FormData();
102
+ fd.append('zip', zipToSend.toBuffer(), { filename: 'zip' });
103
+ fd.append('metadata', JSON.stringify({
104
+ stage: flags.stage,
105
+ version: 'v10.0',
106
+ }), { contentType: 'application/json' });
107
+ try {
108
+ await got_1.default.post(finalUrl, {
109
+ body: fd.getBuffer(),
110
+ headers: fd.getHeaders({
111
+ Authorization: `Basic ${base64Auth}`,
112
+ }),
113
+ });
114
+ if (flags.logs)
115
+ this.log('Data successfully imported');
116
+ }
117
+ catch (e) {
118
+ throw new Error('Failed to write data to the PDF Butler system');
119
+ }
91
120
  });
92
- return { success: resp.statusCode === 200 };
93
121
  }
94
122
  return { success: true };
95
123
  }
@@ -126,6 +154,10 @@ ButlerPbImport.flags = {
126
154
  char: 'f',
127
155
  required: true,
128
156
  }),
157
+ logs: sf_plugins_core_1.Flags.boolean({
158
+ summary: messages.getMessage('flags.logs.summary'),
159
+ char: 'l',
160
+ }),
129
161
  };
130
162
  exports.default = ButlerPbImport;
131
163
  //# sourceMappingURL=import.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"import.js","sourceRoot":"","sources":["../../../../src/commands/butler/pb/import.ts"],"names":[],"mappings":";;AAAA,6BAA8B;AAC9B,kCAAmC;AACnC,iEAA+D;AAC/D,2CAAkE;AAClE,sCAAuC;AACvC,kCAAmC;AACnC,6BAAsB;AAEtB,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;AAMvF,MAAqB,cAAe,SAAQ,2BAA+B;IAoCjE,MAAM,CAAC,aAAa,CAAC,UAAkB;QAC7C,QAAQ,UAAU,EAAE;YAClB,KAAK,OAAO;gBACV,OAAO,0BAA0B,CAAC;YACpC,KAAK,MAAM;gBACT,OAAO,sBAAsB,CAAC;YAChC,KAAK,MAAM;gBACT,OAAO,2BAA2B,CAAC;YACrC,KAAK,KAAK;gBACR,OAAO,0BAA0B,CAAC;YACpC,KAAK,OAAO;gBACV,OAAO,sBAAsB,CAAC;YAChC,KAAK,KAAK;gBACR,OAAO,0BAA0B,CAAC;SACrC;QACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAEM,KAAK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
-
7
- More information about a command. Don't repeat the summary.
8
-
9
- # flags.name.summary
10
-
11
- Description of a flag.
12
-
13
- # flags.name.description
14
-
15
- More information about a flag. Don't repeat the summary.
16
-
17
- # examples
18
-
19
- - <%= config.bin %> <%= command.id %>
1
+ # summary
2
+
3
+ Summary of a command.
4
+
5
+ # description
6
+
7
+ More information about a command. Don't repeat the summary.
8
+
9
+ # flags.name.summary
10
+
11
+ Description of a flag.
12
+
13
+ # flags.name.description
14
+
15
+ More information about a flag. Don't repeat the summary.
16
+
17
+ # examples
18
+
19
+ - <%= config.bin %> <%= command.id %>
20
20
 
21
21
  # flags.target.summary
22
22
 
@@ -49,3 +49,11 @@ Summary for stage.
49
49
  # flags.unzip.summary
50
50
 
51
51
  Summary for unzip.
52
+
53
+ # flags.partial.summary
54
+
55
+ Summary for partial.
56
+
57
+ # flags.logs.summary
58
+
59
+ Summary for logs.
@@ -38,3 +38,7 @@ Summary for stage.
38
38
  # flags.config.summary
39
39
 
40
40
  Summary for config.
41
+
42
+ # flags.logs.summary
43
+
44
+ Summary for logs.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.10",
2
+ "version": "0.0.12",
3
3
  "commands": {
4
4
  "butler:pb:export": {
5
5
  "id": "butler:pb:export",
@@ -89,6 +89,20 @@
89
89
  "char": "u",
90
90
  "summary": "Summary for unzip.",
91
91
  "allowNo": false
92
+ },
93
+ "logs": {
94
+ "name": "logs",
95
+ "type": "boolean",
96
+ "char": "l",
97
+ "summary": "Summary for logs.",
98
+ "allowNo": false
99
+ },
100
+ "partial": {
101
+ "name": "partial",
102
+ "type": "boolean",
103
+ "char": "p",
104
+ "summary": "Summary for partial.",
105
+ "allowNo": false
92
106
  }
93
107
  },
94
108
  "args": {}
@@ -158,6 +172,13 @@
158
172
  "summary": "Summary for config.",
159
173
  "required": true,
160
174
  "multiple": false
175
+ },
176
+ "logs": {
177
+ "name": "logs",
178
+ "type": "boolean",
179
+ "char": "l",
180
+ "summary": "Summary for logs.",
181
+ "allowNo": false
161
182
  }
162
183
  },
163
184
  "args": {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pdfbutler/migration-cli",
3
3
  "description": "[![NPM](https://img.shields.io/npm/v/pdfbutler-migration-cli.svg?label=pdfbutler-migration-cli)](https://www.npmjs.com/package/pdfbutler-migration-cli) [![Downloads/week](https://img.shields.io/npm/dw/pdfbutler-migration-cli.svg)](https://npmjs.org/package/pdfbutler-migration-cli) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/pdfbutler-migration-cli/main/LICENSE.txt)",
4
- "version": "0.0.10",
4
+ "version": "0.0.12",
5
5
  "script": {
6
6
  "postinstall": "sf plugins link @pdfbutler/migration-cli"
7
7
  },