quackage 1.0.13 → 1.0.14

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.
@@ -5,8 +5,8 @@
5
5
  "Description": "A template set for pictunittest ...",
6
6
  "Files": [
7
7
  {
8
- "Hash": "testPicttestjs",
9
- "Path": "test/Pict__test.js",
8
+ "Hash": "testPictQUACKAGEPROJECTNAMECAPtestjs",
9
+ "Path": "test/Pict_QUACKAGEPROJECTNAMECAP_test.js",
10
10
  "Content": "/*\n\tUnit tests for LIBRARYNAMEHERE Basic\n*/\n\nconst _Package = require(`../package.json`);\n\n// This is temporary, but enables unit tests\nconst libBrowserEnv = require('browser-env')\nlibBrowserEnv();\n\nconst Chai = require('chai');\nconst Expect = Chai.expect;\n\nconst libPict = require('pict');\n\nconst configureTestPict = (pPict) =>\n{\n\tlet tmpPict = (typeof(pPict) == 'undefined') ? new libPict() : pPict;\n\ttmpPict.TestData = (\n\t\t{\n\t\t\tReads: [],\n\t\t\tAssignments: [],\n\t\t\tAppends: [],\n\t\t\tGets: []\n\t\t});\n\ttmpPict.ContentAssignment.customReadFunction = (pAddress, pContentType) =>\n\t{\n\t\ttmpPict.TestData.Reads.push(pAddress);\n\t\ttmpPict.log.info(`Mocking a read of type ${pContentType} from Address: ${pAddress}`);\n\t\treturn '';\n\t}\n\ttmpPict.ContentAssignment.customGetElementFunction = (pAddress) =>\n\t{\n\t\ttmpPict.TestData.Gets.push(pAddress);\n\t\ttmpPict.log.info(`Mocking a get of Address: ${pAddress}`);\n\t\treturn '';\n\t}\n\ttmpPict.ContentAssignment.customAppendElementFunction = (pAddress, pContent) =>\n\t{\n\t\ttmpPict.TestData.Appends.push(pAddress);\n\t\ttmpPict.log.info(`Mocking an append of Address: ${pAddress}`, {Content: pContent});\n\t\treturn '';\n\t}\n\ttmpPict.ContentAssignment.customAssignFunction = (pAddress, pContent) =>\n\t{\n\t\ttmpPict.TestData.Assignments.push(pAddress);\n\t\ttmpPict.log.info(`Mocking an assignment of Address: ${pAddress}`, {Content: pContent});\n\t\treturn '';\n\t}\n\n\treturn tmpPict;\n}\n\nconst libPictExtension = require(`../${_Package.main}`);\n\nsuite\n(\n\t`Basic ${_Package.name}v${_Package.version} tests`,\n\t() =>\n\t{\n\t\tsetup(() => { });\n\n\t\tsuite\n\t\t\t(\n\t\t\t\t'Basic Basic Tests',\n\t\t\t\t() =>\n\t\t\t\t{\n\t\t\t\t\ttest(\n\t\t\t\t\t\t\t'Constructor properly crafts an object',\n\t\t\t\t\t\t\t(fDone) =>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlet _Pict = configureTestPict();\n\t\t\t\t\t\t\t\tlet _PictExtension = _Pict.addView({}, 'Pict-Test-{~RandomNumberString:4,9000~}', libPictExtension);\n\t\t\t\t\t\t\t\tExpect(_PictExtension).to.be.an('object');\n\t\t\t\t\t\t\t\treturn fDone();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t}\n);"
11
11
  }
12
12
  ]
@@ -49,8 +49,8 @@
49
49
  "Description": "A template set for unittest ...",
50
50
  "Files": [
51
51
  {
52
- "Hash": "testBasetestjs",
53
- "Path": "test/Base_test.js",
52
+ "Hash": "testQUACKAGEPROJECTNAMECAPBasictestjs",
53
+ "Path": "test/QUACKAGEPROJECTNAMECAP-Basic_test.js",
54
54
  "Content": "/*\n\tUnit tests for {~PascalCaseIdentifier:AppData.Package.name~} {~Data:Record.Scope~}\n*/\n\nconst Chai = require('chai');\nconst Expect = Chai.expect;\n\nconst lib{~PascalCaseIdentifier:AppData.Package.name~} = require(`../{~Data:AppData.Package.main~}`);\n\nsuite\n(\n\t'{~PascalCaseIdentifier:AppData.Package.name~} {~Data:Record.Scope~}',\n\t() =>\n\t{\n\t\tsetup(() => { });\n\n\t\tsuite\n\t\t\t(\n\t\t\t\t'Basic {~Data:Record.Scope~} Tests',\n\t\t\t\t() =>\n\t\t\t\t{\n\t\t\t\t\ttest(\n\t\t\t\t\t\t\t'Object Instantiation # {~RandomNumberString:1,9~}',\n\t\t\t\t\t\t\t(fDone) =>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlet _{~PascalCaseIdentifier:AppData.Package.name~} = new lib{~PascalCaseIdentifier:AppData.Package.name~}();\n\t\t\t\t\t\t\t\tExpect(_{~PascalCaseIdentifier:AppData.Package.name~}).to.be.an('object');\n\t\t\t\t\t\t\t\treturn fDone();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t}\n);"
55
55
  }
56
56
  ]
@@ -12,7 +12,7 @@
12
12
  "<node_internals>/**"
13
13
  ],
14
14
  "program": "${workspaceFolder}/source/Quackage.js",
15
- "args":["buildtemplates", "./templates"]
15
+ "args":["lint", "./templates"]
16
16
  }
17
17
  ]
18
18
  }
package/debug/Clean.sh ADDED
@@ -0,0 +1,5 @@
1
+ ##!/bin/bash
2
+
3
+ echo "Deleting quackage test environment..."
4
+
5
+ rm -rf ./testenv
package/debug/Env.sh ADDED
@@ -0,0 +1,8 @@
1
+ ##!/bin/bash
2
+
3
+ echo "Creating quackage test environment..."
4
+
5
+ mkdir testenv
6
+ cp ../test/packagefiles/clean-debug-package.json testenv/package.json
7
+ cd testenv
8
+ npm install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quackage",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Building. Testing. Quacking.",
5
5
  "main": "source/Quackage.js",
6
6
  "scripts": {
@@ -63,7 +63,7 @@
63
63
  "mocha": "10.2.0",
64
64
  "npm-check-updates": "^16.10.12",
65
65
  "nyc": "^15.1.0",
66
- "pict": "^1.0.81",
66
+ "pict": "^1.0.88",
67
67
  "vinyl-buffer": "^1.0.1",
68
68
  "vinyl-source-stream": "^2.0.0"
69
69
  }
@@ -13,9 +13,9 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
13
13
 
14
14
  this.options.CommandArguments.push({ Name: '<fileset>', Description: 'The boilerplate fileset to generate.' });
15
15
 
16
- this.options.CommandOptions.push({ Name: '-s, --scope', Description: 'A "scope" for the template.', Default: 'Scope' });
17
- this.options.CommandOptions.push({ Name: '-f, --force', Description: 'Force overwrite anything in the package.json; use at your own quacking peril' });
18
- this.options.CommandOptions.push({ Name: '-c, --content', Description: 'An extra content string.', Default: '' });
16
+ this.options.CommandOptions.push({ Name: '-s, --scope [scope]', Description: 'A "scope" for the template (used for things like unit tests)', Default: 'BoilerplateScope' });
17
+ this.options.CommandOptions.push({ Name: '-d, --description [description]', Description: 'An extra content string used as a description', Default: '' });
18
+ this.options.CommandOptions.push({ Name: '-o, --outputfolder [output_folder]', Description: 'Where to write the .quackage-templates.json file', Default: '' });
19
19
 
20
20
  this.options.Aliases.push('boil');
21
21
  this.options.Aliases.push('bp');
@@ -38,7 +38,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
38
38
  let tmpCWDFilesetPath = `${this.fable.AppData.CWD}/.quackage-templates.json`;
39
39
  let tmpHomeFilesetPath = `${libOS.homedir()}/.quackage-templates.json`;
40
40
 
41
- let libFilePersistence = this.defaultServices.FilePersistence;
41
+ let libFilePersistence = this.services.FilePersistence;
42
42
 
43
43
  if (libFilePersistence.existsSync(tmpCWDFilesetPath))
44
44
  {
@@ -58,7 +58,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
58
58
  {
59
59
  this.log.info(`...Boilerplate fileset loaded from [${tmpCWDFilesetPath}]`);
60
60
  this.log.info(`...Merging boilerplate fileset [${tmpCWDFilesetPath}] with [${pFileset}]`);
61
- this.fileSet = this.defaultServices.Utility.extend(this.fileSet, tmpCWDFileset);
61
+ this.fileSet = this.services.Utility.extend(this.fileSet, tmpCWDFileset);
62
62
  }
63
63
  }
64
64
  }
@@ -81,7 +81,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
81
81
  {
82
82
  this.log.info(`...Boilerplate fileset loaded from [${tmpHomeFilesetPath}]`);
83
83
  this.log.info(`...Merging boilerplate fileset [${tmpHomeFilesetPath}] with [${pFileset}]`);
84
- this.fileSet = this.defaultServices.Utility.extend(this.fileSet, tmpHomeFileset);
84
+ this.fileSet = this.services.Utility.extend(this.fileSet, tmpHomeFileset);
85
85
  }
86
86
  }
87
87
  }
@@ -131,7 +131,8 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
131
131
 
132
132
  let tmpFileFolder = libPath.dirname(tmpFilePath);
133
133
 
134
- tmpFilePath = tmpFilePath.replace('QUACKAGEPROJECTNAMECAP', this.defaultServices.DataFormat.capitalizeEachWord(this.fable.AppData.Package.name));
134
+ tmpFilePath = tmpFilePath.replace('QUACKAGEPROJECTNAMECAP', this.services.DataFormat.capitalizeEachWord(this.fable.AppData.Package.name))
135
+ .replace('QUACKAGESCOPE', tmpScope);
135
136
 
136
137
  libFilePersistence.makeFolderRecursive(tmpFileFolder,
137
138
  (pError)=>
@@ -152,7 +153,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
152
153
  {
153
154
  // It exists! Show the user the command to back it up and/or delete it. Don't generate it.
154
155
  this.log.error(`The requested file [${tmpFilePath}] already exists!`);
155
- this.log.info(`To back it up, run: [ mv "${tmpFilePath}" "${tmpFilePath}_QuackageBackup_${this.defaultServices.DataGeneration.randomNumericString(4, 9998)}.bak" ]`);
156
+ this.log.info(`To back it up, run: [ mv "${tmpFilePath}" "${tmpFilePath}_QuackageBackup_${this.services.DataGeneration.randomNumericString(4, 9998)}.bak" ]`);
156
157
  this.log.info(`To delete it, run: [ rm "${tmpFilePath}" ]`);
157
158
  }
158
159
  else
@@ -0,0 +1,156 @@
1
+ const libCommandLineCommand = require('../services/Pict-Service-CommandLineCommand.js');
2
+ const libOS = require('os');
3
+ const libFS = require('fs');
4
+ const libPath = require('path');
5
+
6
+ class QuackageCommandBuildTemplates extends libCommandLineCommand
7
+ {
8
+ constructor(pFable, pManifest, pServiceHash)
9
+ {
10
+ super(pFable, pManifest, pServiceHash);
11
+
12
+ this.options.CommandKeyword = 'buildquackagetemplates';
13
+ this.options.Description = 'Generate boilerplate file set templates for each folder in the passed in path';
14
+
15
+ this.options.CommandArguments.push({ Name: '<folder>', Description: 'The folder path to build templates for.' });
16
+ this.options.Comma
17
+
18
+ this.options.Aliases.push('bqt');
19
+
20
+ this.templateSets = {};
21
+
22
+ // Auto add the command on initialization
23
+ this.addCommand();
24
+ }
25
+
26
+ getTemplateSet(pTemplateSetHash)
27
+ {
28
+ if (!this.templateSets.hasOwnProperty(pTemplateSetHash))
29
+ {
30
+ this.templateSets[pTemplateSetHash] = (
31
+ {
32
+ "Hash": this.services.DataFormat.cleanNonAlphaCharacters(pTemplateSetHash),
33
+ "Name": this.services.DataFormat.cleanNonAlphaCharacters(this.services.DataFormat.capitalizeEachWord(pTemplateSetHash)),
34
+ "Description": `A template set for ${pTemplateSetHash} ...`,
35
+ "Files": []
36
+ });
37
+ }
38
+
39
+ return this.templateSets[pTemplateSetHash];
40
+ }
41
+
42
+ addTemplateToSet(pTemplateSetHash, pTemplateSetRootPath, pTemplateFilePath, pTemplateFileContent, fCallback)
43
+ {
44
+ let tmpTemplateSet = this.getTemplateSet(pTemplateSetHash);
45
+ let tmpTemplateFilePath = pTemplateFilePath;
46
+
47
+ if ((pTemplateSetRootPath.length > 0) && (pTemplateFilePath.length > pTemplateSetRootPath.length))
48
+ {
49
+ tmpTemplateFilePath = pTemplateFilePath.substr(pTemplateSetRootPath.length);
50
+ }
51
+ tmpTemplateFilePath = tmpTemplateFilePath.substr(1);
52
+
53
+ tmpTemplateSet.Files.push(
54
+ {
55
+ "Hash": this.services.DataFormat.cleanNonAlphaCharacters(tmpTemplateFilePath),
56
+ "Path": tmpTemplateFilePath,
57
+ "Content": pTemplateFileContent
58
+ });
59
+
60
+ return fCallback();
61
+ }
62
+
63
+ generateTemplatesRecursively(pTemplateSet, pTemplateSetRootPath, pPath, fCallback)
64
+ {
65
+ libFS.readdir(pPath,
66
+ (pError, pFiles) =>
67
+ {
68
+ this.fable.Utility.eachLimit(pFiles, 1,
69
+ (pFileName, fEnumerationComplete)=>
70
+ {
71
+ let tmpFilePath = libPath.join(pPath, pFileName);
72
+ let tmpStat = libFS.stat(tmpFilePath,
73
+ (pFileStatError, pFileStats) =>
74
+ {
75
+ if (pFileStatError)
76
+ {
77
+ return fEnumerationComplete('File stat error during enumeration:'+pEnumerationError);
78
+ }
79
+
80
+ if (pFileStats && pFileStats.isDirectory())
81
+ {
82
+ return this.generateTemplatesRecursively(pTemplateSet, pTemplateSetRootPath, tmpFilePath, fEnumerationComplete);
83
+ }
84
+ else
85
+ {
86
+ this.log.info(`File [${pFileName}] in [${tmpFilePath}] is being added to template set: ${pTemplateSet}`);
87
+ let tmpFileContent = libFS.readFileSync(tmpFilePath, 'utf8');
88
+ return this.addTemplateToSet(pTemplateSet, pTemplateSetRootPath, tmpFilePath, tmpFileContent, fEnumerationComplete);
89
+ }
90
+ });
91
+ },
92
+ (pEnumerationError) =>
93
+ {
94
+ if (pEnumerationError)
95
+ return fCallback(`Error during bulk catalog of library [${pLibraryName}] folder [${pRelativeFolder}]: ${pEnumerationError}`);
96
+ return fCallback();
97
+ });
98
+ });
99
+ }
100
+
101
+ generateTemplatesFromFolder(pPath, fCallback)
102
+ {
103
+ libFS.readdir(pPath,
104
+ (pError, pFiles) =>
105
+ {
106
+ this.fable.Utility.eachLimit(pFiles, 1,
107
+ (pFileName, fEnumerationComplete)=>
108
+ {
109
+ let tmpFilePath = libPath.join(pPath, pFileName);
110
+ let tmpStat = libFS.stat(tmpFilePath,
111
+ (pFileStatError, pFileStats) =>
112
+ {
113
+ if (pFileStatError)
114
+ {
115
+ return fCallback('File stat error during enumeration:'+pEnumerationError);
116
+ }
117
+
118
+ let tmpSetName = this.services.DataFormat.cleanNonAlphaCharacters(pFileName);
119
+
120
+ if (pFileStats && pFileStats.isDirectory())
121
+ {
122
+ this.log.info(`Root Directory [${tmpFilePath}] being added as its own template set.`);
123
+ this.generateTemplatesRecursively(tmpSetName, tmpFilePath, tmpFilePath, fEnumerationComplete);
124
+ }
125
+ else
126
+ {
127
+ this.log.info(`Root File [${tmpFilePath}] being added as its own template set.`);
128
+ let tmpFileContent = libFS.readFileSync(tmpFilePath, 'utf8');
129
+ return this.addTemplateToSet(tmpSetName, pPath, tmpFilePath, tmpFileContent, fEnumerationComplete);
130
+ }
131
+ });
132
+ },
133
+ (pEnumerationError) =>
134
+ {
135
+ if (pEnumerationError)
136
+ {
137
+ return fCallback(`Error building templates for ${pPath}: ${pEnumerationError}`, pEnumerationError);
138
+ }
139
+ libFS.writeFileSync(`${this.fable.AppData.CWD}/.quackage-templates.json`, (JSON.stringify(this.templateSets, null, 4)));
140
+ return fCallback();
141
+ });
142
+ });
143
+ }
144
+
145
+ run(pPath, pOptions, fCallback)
146
+ {
147
+ let tmpCallback = (typeof(fCallback) === 'function') ? fCallback : ()=>{};
148
+ let tmpCWDFolderPath = libPath.resolve(`${this.fable.AppData.CWD}/${pPath}`);
149
+ // Execute the command
150
+ this.log.info(`Creating boilerplate template(s) for [${tmpCWDFolderPath}]...`);
151
+
152
+ return this.generateTemplatesFromFolder(tmpCWDFolderPath, tmpCallback);
153
+ };
154
+ }
155
+
156
+ module.exports = QuackageCommandBuildTemplates;
@@ -28,8 +28,8 @@ class QuackageCommandBuildTemplates extends libCommandLineCommand
28
28
  {
29
29
  this.templateSets[pTemplateSetHash] = (
30
30
  {
31
- "Hash": this.defaultServices.DataFormat.cleanNonAlphaCharacters(pTemplateSetHash),
32
- "Name": this.defaultServices.DataFormat.cleanNonAlphaCharacters(this.defaultServices.DataFormat.capitalizeEachWord(pTemplateSetHash)),
31
+ "Hash": this.services.DataFormat.cleanNonAlphaCharacters(pTemplateSetHash),
32
+ "Name": this.services.DataFormat.cleanNonAlphaCharacters(this.services.DataFormat.capitalizeEachWord(pTemplateSetHash)),
33
33
  "Description": `A template set for ${pTemplateSetHash} ...`,
34
34
  "Files": []
35
35
  });
@@ -51,7 +51,7 @@ class QuackageCommandBuildTemplates extends libCommandLineCommand
51
51
 
52
52
  tmpTemplateSet.Files.push(
53
53
  {
54
- "Hash": this.defaultServices.DataFormat.cleanNonAlphaCharacters(tmpTemplateFilePath),
54
+ "Hash": this.services.DataFormat.cleanNonAlphaCharacters(tmpTemplateFilePath),
55
55
  "Path": tmpTemplateFilePath,
56
56
  "Content": pTemplateFileContent
57
57
  });
@@ -114,7 +114,7 @@ class QuackageCommandBuildTemplates extends libCommandLineCommand
114
114
  return fCallback('File stat error during enumeration:'+pEnumerationError);
115
115
  }
116
116
 
117
- let tmpSetName = this.defaultServices.DataFormat.cleanNonAlphaCharacters(pFileName);
117
+ let tmpSetName = this.services.DataFormat.cleanNonAlphaCharacters(pFileName);
118
118
 
119
119
  if (pFileStats && pFileStats.isDirectory())
120
120
  {
@@ -27,10 +27,10 @@ class CommandLineCommand extends libPict.ServiceProviderBase
27
27
  if (!this.options.CommandAdded)
28
28
  {
29
29
  // Find the default CommandLineUtility service, or make one if it isn't there yet
30
- let tmpCommandLineUtility = this.defaultServices.CommandLineUtility
30
+ let tmpCommandLineUtility = this.services.CommandLineUtility
31
31
  if (typeof (tmpCommandLineUtility) === 'undefined')
32
32
  {
33
- tmpCommandLineUtility = this.defaultServices.ServiceManager.instantiateService('CommandLineUtility');
33
+ tmpCommandLineUtility = this.fable.ServiceManager.instantiateService('CommandLineUtility');
34
34
  }
35
35
 
36
36
  //_Command.command('command_keyword')
@@ -12,7 +12,7 @@ class CommandLineUtility extends libPict.ServiceProviderBase
12
12
  {
13
13
  constructor(pFable, pOptions, pServiceHash)
14
14
  {
15
- let tmpOptions = Object.assign({}, defaultCommandLineUtilityOptions, pOptions);
15
+ let tmpOptions = Object.assign({}, JSON.parse(JSON.stringify(defaultCommandLineUtilityOptions)), pOptions);
16
16
 
17
17
  super(pFable, tmpOptions, pServiceHash);
18
18