pict-section-form 1.0.144 → 1.0.146
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/.config/code-server/config.yaml +4 -0
- package/.vscode/settings.json +1 -1
- package/Dockerfile_LUXURYCode +31 -0
- package/debug/BuildHarnessTestApp.sh +1 -0
- package/debug/Harness.js +12 -3
- package/debug/PICTSection-TabularManifests.json +164 -38
- package/debug/Step-4-ConvertToCSV.js +3 -0
- package/debug/TabularManifestCSV.csv +70 -69
- package/debug/data/DefaultFormManifest.json +164 -38
- package/debug/data/MathExampleForm-Reconstituted.csv +70 -0
- package/debug/data/MathExampleForm.json +164 -38
- package/debug/data/index.html +2 -0
- package/package.json +7 -4
- package/source/Pict-Section-Form.js +1 -0
- package/source/providers/Pict-Provider-DynamicTabularData.js +60 -41
- package/source/services/ManifestConversionToCSV.js +657 -0
- package/source/services/ManifestFactory.js +39 -2
- package/source/views/Pict-View-DynamicForm.js +13 -1
- package/types/source/Pict-Section-Form.d.ts +1 -0
- package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts.map +1 -1
- package/types/source/services/ManifestConversionToCSV.d.ts +17 -0
- package/types/source/services/ManifestConversionToCSV.d.ts.map +1 -0
- package/types/source/services/ManifestFactory.d.ts.map +1 -1
- package/types/source/views/Pict-View-DynamicForm.d.ts +5 -0
- package/types/source/views/Pict-View-DynamicForm.d.ts.map +1 -1
- package/utility/csvparser/ParseCSV-Program.js +2 -1
- package/utility/csvparser/ParseJSON-Command-GenerateCSV.js +116 -0
|
@@ -369,6 +369,21 @@ class ManifestFactory extends libFableServiceProviderBase
|
|
|
369
369
|
tmpDescriptor.PictForm.SpreadsheetNotes = tmpRecord['Input Notes'];
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
if (tmpRecord['Description'])
|
|
373
|
+
{
|
|
374
|
+
tmpDescriptor.Description = tmpRecord['Description'];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (tmpRecord['Units'])
|
|
378
|
+
{
|
|
379
|
+
tmpDescriptor.PictForm.Units = tmpRecord['Units'];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (tmpRecord['Tooltip'])
|
|
383
|
+
{
|
|
384
|
+
tmpDescriptor.PictForm.Tooltip = tmpRecord['Tooltip'];
|
|
385
|
+
}
|
|
386
|
+
|
|
372
387
|
if ((tmpDescriptor.PictForm.InputType == 'Option') && (tmpRecord['Input Extra']))
|
|
373
388
|
{
|
|
374
389
|
let tmpOptionSet = [];
|
|
@@ -582,6 +597,10 @@ class ManifestFactory extends libFableServiceProviderBase
|
|
|
582
597
|
this.log.error(`Failed to parse Maximum Row Count for ${tmpRecord['Input Hash']}: ${pError}`);
|
|
583
598
|
}
|
|
584
599
|
}
|
|
600
|
+
if (tmpRecord['HideTabularEditingControls'] && ((tmpRecord['HideTabularEditingControls'] == '1') || (tmpRecord['HideTabularEditingControls'].toLowerCase() == 'true') || (tmpRecord['HideTabularEditingControls'].toLowerCase() == 't') || (tmpRecord['HideTabularEditingControls'].toLowerCase() == 'y')))
|
|
601
|
+
{
|
|
602
|
+
tmpGroup.HideTabularEditingControls = true;
|
|
603
|
+
}
|
|
585
604
|
if (tmpRecord['Group Show Title'] && (tmpRecord['Group Show Title'] != ''))
|
|
586
605
|
{
|
|
587
606
|
switch(tmpRecord['Group Show Title'].toLowerCase())
|
|
@@ -616,7 +635,17 @@ class ManifestFactory extends libFableServiceProviderBase
|
|
|
616
635
|
if (tmpRecord.InputType == 'TabularAddress')
|
|
617
636
|
{
|
|
618
637
|
tmpGroup.Layout = 'Tabular';
|
|
619
|
-
|
|
638
|
+
// If the csv defines the GroupRecordSetAddress, use that explicitly
|
|
639
|
+
console.log(`Group ${tmpGroup.Hash} RSA ${tmpRecord['GroupRecordSetAddress']} -> Descriptor ${tmpDescriptor.DataAddress}`)
|
|
640
|
+
if (tmpRecord['GroupRecordSetAddress'] && (typeof(tmpRecord.GroupRecordSetAddress == 'string')) && (tmpRecord.GroupRecordSetAddress.length > 0))
|
|
641
|
+
{
|
|
642
|
+
tmpGroup.RecordSetAddress = tmpRecord.GroupRecordSetAddress;
|
|
643
|
+
}
|
|
644
|
+
else
|
|
645
|
+
{
|
|
646
|
+
tmpGroup.RecordSetAddress = tmpDescriptor.DataAddress;
|
|
647
|
+
}
|
|
648
|
+
// Otherwise fall back to the DataAddress
|
|
620
649
|
tmpGroup.RecordManifest = tmpRecord.SubManifest;
|
|
621
650
|
}
|
|
622
651
|
|
|
@@ -666,6 +695,14 @@ class ManifestFactory extends libFableServiceProviderBase
|
|
|
666
695
|
|
|
667
696
|
if (tmpRecord.DataOnly && tmpDescriptor.PictForm)
|
|
668
697
|
{
|
|
698
|
+
if (tmpDescriptor.PictForm.Group)
|
|
699
|
+
{
|
|
700
|
+
tmpDescriptor.FormGroup = tmpDescriptor.PictForm.Group;
|
|
701
|
+
}
|
|
702
|
+
if (tmpDescriptor.PictForm.Section)
|
|
703
|
+
{
|
|
704
|
+
tmpDescriptor.FormSection = tmpDescriptor.PictForm.Section;
|
|
705
|
+
}
|
|
669
706
|
delete tmpDescriptor.PictForm;
|
|
670
707
|
}
|
|
671
708
|
|
|
@@ -778,7 +815,7 @@ class ManifestFactory extends libFableServiceProviderBase
|
|
|
778
815
|
// Check if there is a Form Name to be set
|
|
779
816
|
if (tmpRecord['Form Name'])
|
|
780
817
|
{
|
|
781
|
-
tmpManifest.FormName = tmpRecord['Form Name'];
|
|
818
|
+
tmpManifest.manifest.FormName = tmpRecord['Form Name'];
|
|
782
819
|
}
|
|
783
820
|
if (tmpRecord['Input Hash'])
|
|
784
821
|
{
|
|
@@ -123,7 +123,6 @@ class PictViewDynamicForm extends libPictViewClass
|
|
|
123
123
|
this.initialBundleLoaded = false;
|
|
124
124
|
|
|
125
125
|
this.fable.ManifestFactory.initializeFormGroups(this);
|
|
126
|
-
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
/**
|
|
@@ -925,6 +924,19 @@ class PictViewDynamicForm extends libPictViewClass
|
|
|
925
924
|
return this.sectionDefinition.Groups[pGroupIndex];
|
|
926
925
|
}
|
|
927
926
|
|
|
927
|
+
/**
|
|
928
|
+
* Returns all groups in the section.
|
|
929
|
+
* @returns {Array}
|
|
930
|
+
*/
|
|
931
|
+
getGroups()
|
|
932
|
+
{
|
|
933
|
+
if (!Array.isArray(this.sectionDefinition.Groups))
|
|
934
|
+
{
|
|
935
|
+
return [];
|
|
936
|
+
}
|
|
937
|
+
return this.sectionDefinition.Groups;
|
|
938
|
+
}
|
|
939
|
+
|
|
928
940
|
/**
|
|
929
941
|
* Get a row for an input form group.
|
|
930
942
|
*
|
|
@@ -8,6 +8,7 @@ declare const _exports: {
|
|
|
8
8
|
PictFormApplication: typeof import("./application/Pict-Application-Form.js");
|
|
9
9
|
PictDynamicLayoutProvider: typeof import("./providers/Pict-Provider-DynamicLayout.js");
|
|
10
10
|
ManifestFactory: typeof import("./services/ManifestFactory.js");
|
|
11
|
+
ManifestConversionToCSV: typeof import("./services/ManifestConversionToCSV.js");
|
|
11
12
|
ExtensionViews: {
|
|
12
13
|
LifecycleVisualization: typeof import("./views/support/Pict-View-PSF-LifeCycle-Visualization.js");
|
|
13
14
|
DebugViewer: typeof import("./views/support/Pict-View-PSF-DebugViewer.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-Provider-DynamicTabularData.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-DynamicTabularData.js"],"names":[],"mappings":";AAaA;;;GAGG;AAEH;;GAEG;AACH;IAEC;;;;;;OAMG;IACH,oBAJW,MAAM,YACN,MAAM,gBACN,MAAM,EAahB;IANA,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IAKV;;;;;;OAMG;IACH,6CAHW,MAAM,GACJ,cAAa,OAAO,CAehC;IAED;;;;;;;OAOG;IACH,+CAJW,MAAM,eACN,MAAM,GACJ,iBAAiB,GAAC,OAAO,CAiBrC;IAED;;;;;;;OAOG;IACH,8CAJW,MAAM,kBACN,MAAM,GACJ,OAAO,MAAO,CAkD1B;IAED;;;;;OAKG;IACH,+CAFW,MAAM,
|
|
1
|
+
{"version":3,"file":"Pict-Provider-DynamicTabularData.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-DynamicTabularData.js"],"names":[],"mappings":";AAaA;;;GAGG;AAEH;;GAEG;AACH;IAEC;;;;;;OAMG;IACH,oBAJW,MAAM,YACN,MAAM,gBACN,MAAM,EAahB;IANA,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IAKV;;;;;;OAMG;IACH,6CAHW,MAAM,GACJ,cAAa,OAAO,CAehC;IAED;;;;;;;OAOG;IACH,+CAJW,MAAM,eACN,MAAM,GACJ,iBAAiB,GAAC,OAAO,CAiBrC;IAED;;;;;;;OAOG;IACH,8CAJW,MAAM,kBACN,MAAM,GACJ,OAAO,MAAO,CAkD1B;IAED;;;;;OAKG;IACH,+CAFW,MAAM,QA0DhB;IAGD;;;;;OAKG;IACH,4DAFW,MAAM,QA2BhB;IAED;;;;;;;;OAQG;IACH,iDALW,MAAM,aACN,MAAM,GAAC,MAAM,gBACb,MAAM,GACJ,OAAO,CA4BnB;IAED;;;;;;;OAOG;IACH,iDAJW,MAAM,aACN,MAAM,GAAC,MAAM,GACX,OAAO,CA2BnB;IAED;;;;;;;OAOG;IACH,+CAJW,MAAM,aACN,MAAM,GAAC,MAAM,GACX,OAAO,CAgCnB;IAGD;;;;;;;OAOG;IACH,+CAJW,MAAM,aACN,MAAM,GAAC,MAAM,GACX,OAAO,CA6DnB;CACD;;;;;AAzaD,kCAAkC;AAClC,6CADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS3B;;;;;UAIW,MAAM"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export = ManifestConversionToCSV;
|
|
2
|
+
declare class ManifestConversionToCSV {
|
|
3
|
+
constructor(pFable: any, pOptions: any, pServiceHash: any);
|
|
4
|
+
/** @type {import('pict') & { instantiateServiceProviderWithoutRegistration: (hash: string, options?: any, uuid?: string) => any }} */
|
|
5
|
+
fable: import("pict") & {
|
|
6
|
+
instantiateServiceProviderWithoutRegistration: (hash: string, options?: any, uuid?: string) => any;
|
|
7
|
+
};
|
|
8
|
+
/** @type {any} */
|
|
9
|
+
log: any;
|
|
10
|
+
/** @type {string} */
|
|
11
|
+
UUID: string;
|
|
12
|
+
CSV_HEADER: string[];
|
|
13
|
+
CSV_COLUMN_MAP: {};
|
|
14
|
+
getRowFromDescriptor(pForm: any, pDescriptorKey: any, pDescriptor: any): false | any[];
|
|
15
|
+
createTabularArrayFromManifests(pManifest: any): any[][];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ManifestConversionToCSV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManifestConversionToCSV.d.ts","sourceRoot":"","sources":["../../../source/services/ManifestConversionToCSV.js"],"names":[],"mappings":";AAEA;IAEI,2DAkEC;IA9DG,sIAAsI;IACtI,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,6CAA6C,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAA;KAAE,CACxH;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IACR,qBAAqB;IACrB,MADW,MAAM,CACR;IAET,qBA8CC;IAGD,mBAAwB;IAQ5B,uFA2JC;IAED,yDAwaC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManifestFactory.d.ts","sourceRoot":"","sources":["../../../source/services/ManifestFactory.js"],"names":[],"mappings":";AAOA;IAEC,2DA4CC;IAtCA,sIAAsI;IACtI,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,6CAA6C,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAA;KAAE,CACxH;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IACR,qBAAqB;IACrB,MADW,MAAM,CACR;IAET,cAAmC;IAcnC,+BAAoC;IAEpC,sBAA2B;IAC3B,oBAAyB;IASzB,2BAA2B;IAE3B,gCAAgD;IAChD,sCAAwC;IACxC,kCAA0C;IAG3C;;;;;OAKG;IACH,2BAHW,MAAM,GACL,MAAM,CASjB;IAED;;;;;;;;;OASG;IACH,uCAwJC;IAED;;;;OAIG;IACH,8CAOC;IAED;;;;;;OAMG;IACH,iCAJW,MAAM,OAiBhB;IAED;;;;;;;OAOG;IACH,mCALW,MAAM,MAAO,cACb,MAAM,OAkBhB;IAED;;;;OAIG;IACH,8BAFa,OAAO,CAenB;IAED;;;;;;;OAOG;IACH,
|
|
1
|
+
{"version":3,"file":"ManifestFactory.d.ts","sourceRoot":"","sources":["../../../source/services/ManifestFactory.js"],"names":[],"mappings":";AAOA;IAEC,2DA4CC;IAtCA,sIAAsI;IACtI,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,6CAA6C,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAA;KAAE,CACxH;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IACR,qBAAqB;IACrB,MADW,MAAM,CACR;IAET,cAAmC;IAcnC,+BAAoC;IAEpC,sBAA2B;IAC3B,oBAAyB;IASzB,2BAA2B;IAE3B,gCAAgD;IAChD,sCAAwC;IACxC,kCAA0C;IAG3C;;;;;OAKG;IACH,2BAHW,MAAM,GACL,MAAM,CASjB;IAED;;;;;;;;;OASG;IACH,uCAwJC;IAED;;;;OAIG;IACH,8CAOC;IAED;;;;;;OAMG;IACH,iCAJW,MAAM,OAiBhB;IAED;;;;;;;OAOG;IACH,mCALW,MAAM,MAAO,cACb,MAAM,OAkBhB;IAED;;;;OAIG;IACH,8BAFa,OAAO,CAenB;IAED;;;;;;;OAOG;IACH,kEAkbC;IAED;;;;;;;;;OASG;IACH,2GAGC;IAED;;;;;;OAMG;IACH,0CAJW,GAAG,GAEF,GAAG,CAwDd;CACD;;+BAGU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC"}
|
|
@@ -178,6 +178,11 @@ declare class PictViewDynamicForm extends libPictViewClass {
|
|
|
178
178
|
* @returns {object|boolean} - The group object if found, or false if the group index is invalid.
|
|
179
179
|
*/
|
|
180
180
|
getGroup(pGroupIndex: number): object | boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Returns all groups in the section.
|
|
183
|
+
* @returns {Array}
|
|
184
|
+
*/
|
|
185
|
+
getGroups(): any[];
|
|
181
186
|
/**
|
|
182
187
|
* Get a row for an input form group.
|
|
183
188
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-View-DynamicForm.d.ts","sourceRoot":"","sources":["../../../source/views/Pict-View-DynamicForm.js"],"names":[],"mappings":";AAYA;;;;;;;GAOG;AACH;IAEC,
|
|
1
|
+
{"version":3,"file":"Pict-View-DynamicForm.d.ts","sourceRoot":"","sources":["../../../source/views/Pict-View-DynamicForm.js"],"names":[],"mappings":";AAYA;;;;;;;GAOG;AACH;IAEC,2DAuGC;IApDA,kCAAkC;IAClC,kBADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACO;IAIrC,uBAAqC;IAGrC,qBAA2H;IAG3H,sBAAwB;IAcxB,+BAA6D;IAmB7D,iCAAuC;IAEvC,eAAmD;IAEnD,4BAAkC;IAClC,6BAAgC;IAKjC;;;;OAIG;IACH,6BAFa,MAAM,CAgBlB;IAED;;;;;;;;OAQG;IACH,wBAFW,MAAM,QAqDhB;IAGD;;;;;;OAMG;IACH,gCAJW,MAAM,eACN,MAAM,aACN,MAAM,QA4DhB;IAED;;;;;;;;OAQG;IACH,uBAJW,MAAM,U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CACD;;;;;AAn7CD,kCAAkC;AAClC,qCADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAC6D"}
|
|
@@ -22,7 +22,8 @@ let _Program = new libPictCommandLineUtility(_ProgramConfiguration,
|
|
|
22
22
|
[
|
|
23
23
|
require('./ParseCSV-Command-Inject.js'),
|
|
24
24
|
require('./ParseCSV-Command-Parse.js'),
|
|
25
|
-
require('./ParseCSV-Command-BuildDistilling.js')
|
|
25
|
+
require('./ParseCSV-Command-BuildDistilling.js'),
|
|
26
|
+
require('./ParseJSON-Command-GenerateCSV.js')
|
|
26
27
|
]);
|
|
27
28
|
_Program.LogNoisiness = 4;
|
|
28
29
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
|
|
2
|
+
let libPictCommandLineUtility = require('pict-service-commandlineutility');
|
|
3
|
+
|
|
4
|
+
let libPictManifestConversionToCSV = require('../../source/services/ManifestConversionToCSV.js');
|
|
5
|
+
|
|
6
|
+
const libFS = require('fs');
|
|
7
|
+
const libPath = require('path');
|
|
8
|
+
|
|
9
|
+
class ImportCSVCommand extends libPictCommandLineUtility.ServiceCommandLineCommand
|
|
10
|
+
{
|
|
11
|
+
constructor(pFable, pSettings, pServiceHash)
|
|
12
|
+
{
|
|
13
|
+
super(pFable, pSettings, pServiceHash);
|
|
14
|
+
|
|
15
|
+
this.options.CommandKeyword = 'converttocsv';
|
|
16
|
+
this.options.Description = 'Convert a manifest to a CSV file.';
|
|
17
|
+
|
|
18
|
+
this.options.CommandArguments.push({ Name: '<json_manifest_file>', Description: 'The manifest file to convert to a CSV.' });
|
|
19
|
+
|
|
20
|
+
this.options.CommandOptions.push({ Name: '-o, --output [filename]', Description: 'The output file to write the csv to; defaults to the [Scope.csv]'});
|
|
21
|
+
this.options.CommandOptions.push({ Name: '-d, --directory [directory]', Description: 'The directory to output the manifest and other export files to.', Default: './data/'});
|
|
22
|
+
|
|
23
|
+
this.addCommand();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
onRunAsync(fCallback)
|
|
27
|
+
{
|
|
28
|
+
let tmpManifestFileName = this.ArgumentString;
|
|
29
|
+
|
|
30
|
+
if ((!tmpManifestFileName) || (typeof(tmpManifestFileName) != 'string') || (tmpManifestFileName.length === 0))
|
|
31
|
+
{
|
|
32
|
+
this.log.error('No valid manifest filename provided.');
|
|
33
|
+
return fCallback();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Do some input file housekeeping
|
|
37
|
+
let tmpManifestFilePath = libPath.resolve(tmpManifestFileName);
|
|
38
|
+
if (!this.fable.FilePersistence.existsSync(tmpManifestFilePath))
|
|
39
|
+
{
|
|
40
|
+
this.fable.log.error(`File [${tmpManifestFilePath}] does not exist. Checking in the current working directory...`);
|
|
41
|
+
tmpManifestFilePath = libPath.join(process.cwd(), tmpManifestFileName);
|
|
42
|
+
if (!this.fable.FilePersistence.existsSync(tmpManifestFilePath))
|
|
43
|
+
{
|
|
44
|
+
this.fable.log.error(`File [${tmpManifestFilePath}] does not exist in the current working directory. Could not parse input manifest file. Aborting.`);
|
|
45
|
+
return fCallback();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let tmpManifestData = this.fable.FilePersistence.readFileSync(tmpManifestFilePath, { encoding: 'utf8' });
|
|
50
|
+
let tmpManifest = null;
|
|
51
|
+
try
|
|
52
|
+
{
|
|
53
|
+
tmpManifest = JSON.parse(tmpManifestData);
|
|
54
|
+
}
|
|
55
|
+
catch(pError)
|
|
56
|
+
{
|
|
57
|
+
this.fable.log.error(`Could not parse manifest file [${tmpManifestFilePath}] as JSON. Aborting.`);
|
|
58
|
+
return fCallback();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Load the manifest to CSV conversion service
|
|
62
|
+
this.fable.addAndInstantiateServiceType('ManifestConversionToCSV', libPictManifestConversionToCSV);
|
|
63
|
+
|
|
64
|
+
let tmpCSVDataArray = this.fable.ManifestConversionToCSV.createTabularArrayFromManifests(tmpManifest);
|
|
65
|
+
|
|
66
|
+
// Determine output file name
|
|
67
|
+
let tmpOutputFileName = this.CommandOptions.output;
|
|
68
|
+
if ((!tmpOutputFileName) || (typeof(tmpOutputFileName) != 'string') || (tmpOutputFileName.length === 0))
|
|
69
|
+
{
|
|
70
|
+
let tmpScope = 'Default';
|
|
71
|
+
if ((tmpManifest) && (tmpManifest.Scope))
|
|
72
|
+
{
|
|
73
|
+
tmpScope = tmpManifest.Scope;
|
|
74
|
+
}
|
|
75
|
+
if ((tmpManifest) && (tmpManifest.Form))
|
|
76
|
+
{
|
|
77
|
+
tmpScope = tmpManifest.Form;
|
|
78
|
+
}
|
|
79
|
+
tmpOutputFileName = `${tmpScope}.csv`;
|
|
80
|
+
}
|
|
81
|
+
tmpOutputFileName = libPath.resolve(tmpOutputFileName);
|
|
82
|
+
|
|
83
|
+
// Write the CSV data to file -- first take the tabular array and turn it into a CSV string
|
|
84
|
+
let tmpCSVLines = [];
|
|
85
|
+
for (let tmpRowIndex = 0; tmpRowIndex < tmpCSVDataArray.length; tmpRowIndex++)
|
|
86
|
+
{
|
|
87
|
+
let tmpRow = tmpCSVDataArray[tmpRowIndex];
|
|
88
|
+
let tmpEscapedRow = [];
|
|
89
|
+
for (let tmpColumnIndex = 0; tmpColumnIndex < tmpRow.length; tmpColumnIndex++)
|
|
90
|
+
{
|
|
91
|
+
let tmpCell = tmpRow[tmpColumnIndex];
|
|
92
|
+
if ((typeof(tmpCell) === 'string') && ((tmpCell.indexOf(',') >= 0) || (tmpCell.indexOf('"') >= 0) || (tmpCell.indexOf('\n') >= 0)))
|
|
93
|
+
{
|
|
94
|
+
// Escape quotes
|
|
95
|
+
let tmpEscapedCell = tmpCell.replace(/"/g, '""');
|
|
96
|
+
// Wrap in quotes
|
|
97
|
+
tmpEscapedCell = `"${tmpEscapedCell}"`;
|
|
98
|
+
tmpEscapedRow.push(tmpEscapedCell);
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
{
|
|
102
|
+
tmpEscapedRow.push(tmpCell);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
tmpCSVLines.push(tmpEscapedRow.join(','));
|
|
106
|
+
}
|
|
107
|
+
let tmpCSVDataString = tmpCSVLines.join('\n');
|
|
108
|
+
|
|
109
|
+
this.fable.FilePersistence.writeFileSync(tmpOutputFileName, tmpCSVDataString, { encoding: 'utf8' });
|
|
110
|
+
this.fable.log.info(`Wrote CSV data (length ${tmpCSVDataString.length}) to file [${tmpOutputFileName}].`);
|
|
111
|
+
|
|
112
|
+
return fCallback();
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = ImportCSVCommand;
|