quackage 1.0.16 → 1.0.18

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.
@@ -51,7 +51,7 @@
51
51
  {
52
52
  "Hash": "testQUACKAGEPROJECTNAMECAPBasictestjs",
53
53
  "Path": "test/QUACKAGEPROJECTNAMECAP-Basic_test.js",
54
- "Content": "/*\n\tUnit tests for {~PascalCaseIdentifier:AppData.Package.name~} v.${_Package.version} {~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~} Suite',\n\t() =>\n\t{\n\t\tsetup(() => { });\n\n\t\tsuite\n\t\t\t(\n\t\t\t\t'Basic ${_Package.name}.v.${_Package.version} {~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);"
54
+ "Content": "/*\n\tUnit tests for {~PascalCaseIdentifier:AppData.Package.name~} v.{~D:AppData.Package.version~} {~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~} Suite',\n\t() =>\n\t{\n\t\tsetup(() => { });\n\n\t\tsuite\n\t\t\t(\n\t\t\t\t'Basic {~D:_Package.name~}.v.{~D:_Package.version~} {~D: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',\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
  ]
57
57
  },
@@ -11,7 +11,7 @@
11
11
  "skipFiles": [
12
12
  "<node_internals>/**"
13
13
  ],
14
- "program": "${workspaceFolder}/source/Quackage.js",
14
+ "program": "${workspaceFolder}/debug/Harness.js",
15
15
  "args":["lint", "./templates"]
16
16
  }
17
17
  ]
package/debug/Harness.js CHANGED
@@ -1 +1,5 @@
1
1
  console.log('Fancy debug harness here. Shame if it would get quacked.');
2
+
3
+ let libQuackage = require('../source/Quackage-CLIProgram.js');
4
+
5
+ libQuackage.run(['node', 'Harness.js', 'explain-config']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quackage",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Building. Testing. Quacking.",
5
5
  "main": "source/Quackage.js",
6
6
  "scripts": {
@@ -11,8 +11,8 @@
11
11
  "build": "./node_modules/.bin/gulp build"
12
12
  },
13
13
  "bin": {
14
- "quack": "./cli/quack",
15
- "qua": "./cli/quack"
14
+ "quack": "./source/Quackage-Run.js",
15
+ "qua": "./source/Quackage-Run.js"
16
16
  },
17
17
  "mocha": {
18
18
  "diff": true,
@@ -63,8 +63,11 @@
63
63
  "mocha": "10.2.0",
64
64
  "npm-check-updates": "^16.10.13",
65
65
  "nyc": "^15.1.0",
66
- "pict": "^1.0.113",
66
+ "pict-service-commandlineutility": "^1.0.5",
67
+ "resolve-package-path": "^4.0.3",
68
+ "resolve-pkg": "^2.0.0",
67
69
  "vinyl-buffer": "^1.0.1",
68
70
  "vinyl-source-stream": "^2.0.0"
69
- }
71
+ },
72
+ "devDependencies": {}
70
73
  }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "default_package",
3
+ "version": "1.0.0",
4
+ "description": "The default quackage package json.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC"
11
+ }
@@ -48,10 +48,10 @@
48
48
  {
49
49
  "start": "node {~Data:AppData.Package.main~}",
50
50
 
51
- "test": "./node_modules/.bin/mocha -u tdd -R spec",
52
- "tests": "./node_modules/mocha/bin/_mocha -u tdd --exit -R spec --grep",
51
+ "test": "npx mocha -u tdd -R spec",
52
+ "tests": "npx mocha -u tdd --exit -R spec --grep",
53
53
 
54
- "coverage": "./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec",
54
+ "coverage": "npx nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec",
55
55
 
56
56
  "build": "npx quack build",
57
57
 
@@ -0,0 +1,52 @@
1
+ const libCLIProgram = require('pict-service-commandlineutility');
2
+
3
+ let _Pict = new libCLIProgram(
4
+ {
5
+ Product: 'Quackage',
6
+ Version: '0.0.1',
7
+
8
+ Command: 'hl-record-downloader',
9
+ Description: 'Download an array of records from Headlight.',
10
+
11
+ DefaultProgramConfiguration: require('./Default-Quackage-Configuration.json'),
12
+
13
+ // TODO: Should this use a shared config?
14
+ ProgramConfigurationFileName: '.quackage.json',
15
+ AutoGatherProgramConfiguration: true,
16
+ AutoAddConfigurationExplanationCommand: true
17
+ },
18
+ [
19
+ require('./commands/Quackage-Command-UpdatePackage.js'),
20
+ require('./commands/Quackage-Command-Lint.js'),
21
+ require('./commands/Quackage-Command-Build.js'),
22
+ require('./commands/Quackage-Command-Boilerplate.js'),
23
+ require('./commands/Quackage-Command-BuildTemplates.js'),
24
+ require('./commands/Quackage-Command-ListTemplates.js')
25
+ ]);
26
+
27
+ // Instantiate the file persistence service
28
+ _Pict.serviceManager.instantiateServiceProvider('FilePersistence');
29
+ _Pict.serviceManager.instantiateServiceProvider('DataGeneration');
30
+ // Add the Quackage Process Management service
31
+ _Pict.serviceManager.addAndInstantiateServiceType('QuackageProcess', require('./services/Quackage-Execute-Process.js'));
32
+
33
+ // Grab the current working directory for the quackage
34
+ _Pict.AppData.CWD = _Pict.QuackageProcess.cwd();
35
+ _Pict.AppData.QuackageFolder = _Pict.QuackageProcess.quackageFolder();
36
+
37
+ // Check that a package.json is in the folder we are quacking from
38
+ try
39
+ {
40
+ _Pict.AppData.Package = require(`${_Pict.AppData.CWD}/package.json`);
41
+ }
42
+ catch (pError)
43
+ {
44
+ _Pict.log.error(`No package.json found in [${_Pict.AppData.CWD}]. Please run quackage from a folder with a package.json file for maximum awesome.`);
45
+ _Pict.log.info(`Loading a default package.json...`);
46
+ _Pict.AppData.Package = require('./Default-Package.json');
47
+ }
48
+ finally
49
+ {
50
+ }
51
+
52
+ module.exports = _Pict;
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ let libQuackage = require('./Quackage-CLIProgram.js');
3
+ libQuackage.run();
@@ -1,4 +1,4 @@
1
- const libCommandLineCommand = require('../services/Pict-Service-CommandLineCommand.js');
1
+ const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
2
2
  const libOS = require('os');
3
3
  const libPath = require('path');
4
4
 
@@ -13,15 +13,11 @@ 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 [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: '' });
16
+ this.options.CommandOptions.push({ Name: '-s, --scope [scope]', Description: 'A "scope" for the template (used for things like unit tests)', Default: 'Default' });
19
17
 
20
18
  this.options.Aliases.push('boil');
21
19
  this.options.Aliases.push('bp');
22
20
 
23
- this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.fable.AppData.QuackagePackage, null, 4));
24
-
25
21
  try
26
22
  {
27
23
  this.fileSet = require('../../.quackage-templates.json');
@@ -36,11 +32,12 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
36
32
  this.addCommand();
37
33
  }
38
34
 
39
- run(pFileset, pOptions, fCallback)
35
+ onRunAsync(fCallback)
40
36
  {
41
- let tmpScope = pOptions.scope;
37
+ let tmpTemplateFileSet = this.ArgumentString;
38
+ let tmpScope = this.CommandOptions.scope;
42
39
  // Execute the command
43
- this.log.info(`Creating boilerplate file(s) for [${pFileset}] Scoped as ${tmpScope}...`);
40
+ this.log.info(`Creating boilerplate file(s) for [${tmpTemplateFileSet}] Scoped as ${tmpScope}...`);
44
41
 
45
42
  // Check if there is a .quackage-boilerplate.json in either the current directory or the user's home directory.
46
43
  let tmpCWDFilesetPath = `${this.fable.AppData.CWD}/.quackage-templates.json`;
@@ -65,7 +62,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
65
62
  if (tmpCWDFileset)
66
63
  {
67
64
  this.log.info(`...Boilerplate fileset loaded from [${tmpCWDFilesetPath}]`);
68
- this.log.info(`...Merging boilerplate fileset [${tmpCWDFilesetPath}] with [${pFileset}]`);
65
+ this.log.info(`...Merging boilerplate fileset [${tmpCWDFilesetPath}] with [${tmpTemplateFileSet}]`);
69
66
  this.fileSet = this.services.Utility.extend(this.fileSet, tmpCWDFileset);
70
67
  }
71
68
  }
@@ -88,30 +85,26 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
88
85
  if (tmpHomeFileset)
89
86
  {
90
87
  this.log.info(`...Boilerplate fileset loaded from [${tmpHomeFilesetPath}]`);
91
- this.log.info(`...Merging boilerplate fileset [${tmpHomeFilesetPath}] with [${pFileset}]`);
88
+ this.log.info(`...Merging boilerplate fileset [${tmpHomeFilesetPath}] with [${tmpTemplateFileSet}]`);
92
89
  this.fileSet = this.services.Utility.extend(this.fileSet, tmpHomeFileset);
93
90
  }
94
91
  }
95
92
  }
96
93
 
97
94
  // Check if the fileset exists
98
- if (!this.fileSet[pFileset])
95
+ if (!this.fileSet[tmpTemplateFileSet])
99
96
  {
100
- this.log.error(`The requested fileset [${pFileset}] does not exist!`);
101
- if (typeof (fCallback) == 'function')
102
- {
103
- return fCallback();
104
- }
105
- return false;
97
+ this.log.error(`The requested fileset [${tmpTemplateFileSet}] does not exist!`);
98
+ return fCallback();
106
99
  }
107
100
 
108
101
  // Build the boilerplate state
109
- let tmpBoilerPlateRecord = this.fileSet[pFileset];
110
- tmpBoilerPlateRecord.FileSetName = pFileset;
102
+ let tmpBoilerPlateRecord = this.fileSet[tmpTemplateFileSet];
103
+ tmpBoilerPlateRecord.FileSetName = tmpTemplateFileSet;
111
104
 
112
105
  tmpBoilerPlateRecord.Scope = tmpScope;
113
- tmpBoilerPlateRecord.Content = (typeof(pOptions.content) == 'string') ? pOptions.content : '';
114
- tmpBoilerPlateRecord.CommandOptions = pOptions;
106
+ tmpBoilerPlateRecord.Content = (typeof(this.CommandOptions.content) == 'string') ? this.CommandOptions.content : '';
107
+ tmpBoilerPlateRecord.CommandOptions = this.CommandOptions;
115
108
 
116
109
  // Load each template in the fileset into the template provider
117
110
  for (let i = 0; i < tmpBoilerPlateRecord.Files.length; i++)
@@ -130,55 +123,57 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
130
123
  }
131
124
  }
132
125
 
133
- for (let i = 0; i < tmpBoilerPlateRecord.Files.length; i++)
134
- {
135
- // Check if each file exists
136
- let tmpFile = tmpBoilerPlateRecord.Files[i];
137
- // File paths are templates too!
138
- let tmpFilePath = libFilePersistence.joinPath(this.fable.parseTemplate(tmpFile.Path, tmpBoilerPlateRecord));
139
-
140
- let tmpFileFolder = libPath.dirname(tmpFilePath);
141
-
142
- tmpFilePath = tmpFilePath.replace('QUACKAGEPROJECTNAMECAP', this.services.DataFormat.capitalizeEachWord(this.fable.AppData.Package.name))
143
- .replace('QUACKAGESCOPE', tmpScope);
144
-
145
- libFilePersistence.makeFolderRecursive(tmpFileFolder,
146
- (pError)=>
147
- {
148
- if (pError)
149
- {
150
- this.log.error(`Error creating folder [${tmpFileFolder}] for boilerplate scope [${tmpScope}]: ${pError.message}`);
151
- }
126
+ this.fable.Utility.eachLimit(tmpBoilerPlateRecord.Files, 1,
127
+ (pFile, fFolderCallback)=>
128
+ {
129
+ // Check if each file exists
130
+ let tmpFile = pFile;
131
+ // File paths are templates too!
132
+ let tmpFilePath = libFilePersistence.joinPath(this.fable.parseTemplate(tmpFile.Path, tmpBoilerPlateRecord));
152
133
 
153
- if (tmpBoilerPlateRecord.hasOwnProperty('options'))
154
- {
155
- tmpBoilerPlateRecord.options = pOptions;
156
- }
134
+ let tmpFileFolder = libPath.dirname(tmpFilePath);
157
135
 
158
- // Write the file
159
- if (libFilePersistence.existsSync(tmpFilePath) && !pOptions.force)
160
- {
161
- // It exists! Show the user the command to back it up and/or delete it. Don't generate it.
162
- this.log.error(`The requested file [${tmpFilePath}] already exists!`);
163
- this.log.info(`To back it up, run: [ mv "${tmpFilePath}" "${tmpFilePath}_QuackageBackup_${this.services.DataGeneration.randomNumericString(4, 9998)}.bak" ]`);
164
- this.log.info(`To delete it, run: [ rm "${tmpFilePath}" ]`);
165
- }
166
- else
167
- {
168
- // It doesn't exist! Generate it.
169
- this.log.info(`Writing boilerplate file [${tmpFilePath}]!`);
170
- // Keep in mind the templates also have access to the package.json and the .quackage.json data in the AppData object.
171
- libFilePersistence.writeFileSync(tmpFilePath, this.fable.parseTemplate(tmpFile.Content, tmpBoilerPlateRecord));
172
- }
136
+ tmpFilePath = tmpFilePath.replace('QUACKAGEPROJECTNAMECAP', this.services.DataFormat.capitalizeEachWord(this.fable.AppData.Package.name))
137
+ .replace('QUACKAGESCOPE', tmpScope);
173
138
 
174
- if (typeof (fCallback) == 'function')
139
+ libFilePersistence.makeFolderRecursive(tmpFileFolder,
140
+ (pError)=>
175
141
  {
176
- return fCallback();
177
- }
178
- });
142
+ if (pError)
143
+ {
144
+ this.log.error(`Error creating folder [${tmpFileFolder}] for boilerplate scope [${tmpScope}]: ${pError.message}`);
145
+ }
146
+
147
+ if (tmpBoilerPlateRecord.hasOwnProperty('options'))
148
+ {
149
+ tmpBoilerPlateRecord.options = this.CommandOptions;
150
+ }
151
+
152
+ // Write the file
153
+ if (libFilePersistence.existsSync(tmpFilePath) && !this.CommandOptions.force)
154
+ {
155
+ // It exists! Show the user the command to back it up and/or delete it. Don't generate it.
156
+ this.log.error(`The requested file [${tmpFilePath}] already exists!`);
157
+ this.log.info(`To back it up, run: [ mv "${tmpFilePath}" "${tmpFilePath}_QuackageBackup_${this.services.DataGeneration.randomNumericString(4, 9998)}.bak" ]`);
158
+ this.log.info(`To delete it, run: [ rm "${tmpFilePath}" ]`);
159
+ }
160
+ else
161
+ {
162
+ // It doesn't exist! Generate it.
163
+ this.log.info(`Writing boilerplate file [${tmpFilePath}]!`);
164
+ // Keep in mind the templates also have access to the package.json and the .quackage.json data in the AppData object.
165
+ libFilePersistence.writeFileSync(tmpFilePath, this.fable.parseTemplate(tmpFile.Content, tmpBoilerPlateRecord));
166
+ }
167
+
168
+ return fFolderCallback();
169
+ });
170
+ },(pError)=>
171
+ {
172
+ return fCallback();
173
+ });
179
174
 
180
175
  }
181
176
  };
182
- }
177
+
183
178
 
184
179
  module.exports = QuackageCommandBoilerplate;
@@ -1,5 +1,5 @@
1
+ const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
1
2
  const libFS = require('fs');
2
- const libCommandLineCommand = require('../services/Pict-Service-CommandLineCommand.js');
3
3
 
4
4
  class QuackageCommandBuild extends libCommandLineCommand
5
5
  {
@@ -10,36 +10,28 @@ class QuackageCommandBuild extends libCommandLineCommand
10
10
  this.options.CommandKeyword = 'build';
11
11
  this.options.Description = 'Build your npm module into a dist folder';
12
12
 
13
- this.fable.TemplateProvider.addTemplate('Gulpfile-Configuration', JSON.stringify(this.fable.AppData.QuackagePackage.GulpfileConfiguration, null, 4));
14
- this.fable.TemplateProvider.addTemplate('Gulpfile-QuackageBase', this.fable.AppData.QuackagePackage.QuackageBaseGulpfile);
15
-
16
- this.options.CommandArguments.push({ Name: '[buildactions]', Description: 'The optional build action(s) to execute; otherwise run all of them', Default: 'ALL' });
17
-
18
13
  // Auto add the command on initialization
19
14
  this.addCommand();
20
15
  }
21
16
 
22
- run(pArgumentString, pOptions, pCommand, fCallback)
17
+ onRunAsync(fCallback)
23
18
  {
24
- let tmpActionsToExecute = pArgumentString.toUpperCase();
25
- let tmpActionSet = [];
19
+ this.fable.TemplateProvider.addTemplate('Gulpfile-Configuration', JSON.stringify(this.pict.ProgramConfiguration.GulpfileConfiguration, null, 4));
20
+ this.fable.TemplateProvider.addTemplate('Gulpfile-QuackageBase', this.pict.ProgramConfiguration.QuackageBaseGulpfile);
26
21
 
27
- let tmpOptions = pOptions;
22
+ let tmpActionSet = [];
28
23
 
29
- this.log.info(`Building browserified and minified versions of your module ...`, tmpOptions);
24
+ this.log.info(`Building browserified and minified versions of your module ...`);
30
25
 
31
26
  // ##. Figure out which actions to execute
32
- for (let i = 0; i < this.fable.AppData.QuackagePackage.GulpExecutions.length; i++)
27
+ for (let i = 0; i < this.pict.ProgramConfiguration.GulpExecutions.length; i++)
33
28
  {
34
- if (tmpActionsToExecute == 'ALL' || tmpActionsToExecute.includes(this.fable.AppData.QuackagePackage.GulpExecutions[i].Name.toUpperCase()))
35
- {
36
- tmpActionSet.push(this.fable.AppData.QuackagePackage.GulpExecutions[i]);
37
- }
29
+ tmpActionSet.push(this.pict.ProgramConfiguration.GulpExecutions[i]);
38
30
  }
39
31
 
40
32
  if (tmpActionSet.length < 1)
41
33
  {
42
- this.log.error(`No actions to execute for the configuration hash [${pString}]`);
34
+ this.log.error(`No actions to execute for building -- check your quackage configuration!`);
43
35
  return false;
44
36
  }
45
37
 
@@ -65,7 +57,7 @@ class QuackageCommandBuild extends libCommandLineCommand
65
57
  }
66
58
 
67
59
  // ## .babelrc
68
- if (this.fable.AppData.QuackagePackage.DefaultBabelRC)
60
+ if (this.pict.ProgramConfiguration.DefaultBabelRC)
69
61
  {
70
62
  if (libFS.existsSync(`${this.fable.AppData.CWD}/.babelrc`))
71
63
  {
@@ -73,7 +65,7 @@ class QuackageCommandBuild extends libCommandLineCommand
73
65
  }
74
66
  else
75
67
  {
76
- libFS.writeFileSync(`${this.fable.AppData.CWD}/.babelrc`, JSON.stringify(this.fable.AppData.QuackagePackage.DefaultBabelRC, null, 4));
68
+ libFS.writeFileSync(`${this.fable.AppData.CWD}/.babelrc`, JSON.stringify(this.pict.ProgramConfiguration.DefaultBabelRC, null, 4));
77
69
  }
78
70
  }
79
71
 
@@ -92,19 +84,17 @@ class QuackageCommandBuild extends libCommandLineCommand
92
84
  (pError) =>
93
85
  {
94
86
  // Now process the CopyAfterBuild directives
95
- if (this.fable.AppData.QuackagePackage.CopyAfterBuild.length > 0)
87
+ if (this.pict.ProgramConfiguration.CopyAfterBuild.length > 0)
96
88
  {
97
- //this.log.info(`Copying the following files to :`, { Files: this.fable.AppData.QuackagePackage.CopyAfterBuild });
98
- for (let i = 0; i < this.fable.AppData.QuackagePackage.CopyAfterBuild.length; i++)
89
+ //this.log.info(`Copying the following files to :`, { Files: this.pict.ProgramConfiguration.CopyAfterBuild });
90
+ for (let i = 0; i < this.pict.ProgramConfiguration.CopyAfterBuild.length; i++)
99
91
  {
100
92
  // TODO: FilePersistence needs a copy recursive with globbing.
101
- //libFS.copyFileSync(`${this.fable.AppData.CWD}/${this.fable.AppData.QuackagePackage.CopyAfterBuild[i]}`, `${this.fable.AppData.CWD}/dist/${this.fable.AppData.QuackagePackage.CopyAfterBuild[i]}`);
93
+ //libFS.copyFileSync(`${this.fable.AppData.CWD}/${this.pict.ProgramConfiguration.CopyAfterBuild[i]}`, `${this.fable.AppData.CWD}/dist/${this.pict.ProgramConfiguration.CopyAfterBuild[i]}`);
102
94
  }
103
95
  }
104
- if (typeof (fCallback) == 'function')
105
- {
106
- return fCallback(pError);
107
- }
96
+
97
+ return fCallback(pError);
108
98
  });
109
99
  };
110
100
  }
@@ -1,4 +1,4 @@
1
- const libCommandLineCommand = require('../services/Pict-Service-CommandLineCommand.js');
1
+ const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
2
2
  const libOS = require('os');
3
3
  const libFS = require('fs');
4
4
  const libPath = require('path');
@@ -156,14 +156,13 @@ class QuackageCommandBuildTemplates extends libCommandLineCommand
156
156
  });
157
157
  }
158
158
 
159
- run(pPath, pOptions, fCallback)
159
+ onRunAsync(fCallback)
160
160
  {
161
- let tmpCallback = (typeof(fCallback) === 'function') ? fCallback : ()=>{};
162
- let tmpCWDFolderPath = libPath.resolve(`${this.fable.AppData.CWD}/${pPath}`);
161
+ let tmpPath = this.ArgumentString;
162
+ let tmpCWDFolderPath = libPath.resolve(`${this.fable.AppData.CWD}/${tmpPath}`);
163
163
  // Execute the command
164
164
  this.log.info(`Creating template(s) for [${tmpCWDFolderPath}] into "./quackage-templates.json"...`);
165
-
166
- return this.generateTemplatesFromFolder(tmpCWDFolderPath, tmpCallback);
165
+ return this.generateTemplatesFromFolder(tmpCWDFolderPath, fCallback);
167
166
  };
168
167
  }
169
168
 
@@ -1,4 +1,4 @@
1
- const libCommandLineCommand = require('../services/Pict-Service-CommandLineCommand.js');
1
+ const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
2
2
 
3
3
  class QuackageCommandLint extends libCommandLineCommand
4
4
  {
@@ -9,14 +9,14 @@ class QuackageCommandLint extends libCommandLineCommand
9
9
  this.options.CommandKeyword = 'lint';
10
10
  this.options.Description = 'Check your package.json for testing, building and luxury configurations';
11
11
 
12
- this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.fable.AppData.QuackagePackage, null, 4));
13
-
14
12
  // Auto add the command on initialization
15
13
  this.addCommand();
16
14
  }
17
15
 
18
- run(pOptions, pCommand, fCallback)
16
+ onRunAsync(fCallback)
19
17
  {
18
+ this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.pict.ProgramConfiguration, null, 4));
19
+
20
20
  // Execute the command
21
21
  this.log.info(`Linting package.json...`);
22
22
 
@@ -75,10 +75,7 @@ class QuackageCommandLint extends libCommandLineCommand
75
75
  }
76
76
  }
77
77
 
78
- if (typeof (fCallback) == 'function')
79
- {
80
- return fCallback();
81
- }
78
+ return fCallback();
82
79
  };
83
80
  }
84
81
 
@@ -1,4 +1,4 @@
1
- const libCommandLineCommand = require('../services/Pict-Service-CommandLineCommand.js');
1
+ const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
2
2
  const libOS = require('os');
3
3
  const libPath = require('path');
4
4
 
@@ -14,7 +14,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
14
14
  this.options.Aliases.push('list');
15
15
  this.options.Aliases.push('lt');
16
16
 
17
- this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.fable.AppData.QuackagePackage, null, 4));
17
+ this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.pict.ProgramConfiguration, null, 4));
18
18
 
19
19
  try
20
20
  {
@@ -30,11 +30,10 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
30
30
  this.addCommand();
31
31
  }
32
32
 
33
- run(pFileset, pOptions, fCallback)
33
+ onRunAsync(fCallback)
34
34
  {
35
- let tmpScope = pOptions.scope;
36
35
  // Execute the command
37
- this.log.info(`Creating boilerplate file(s) for [${pFileset}] Scoped as ${tmpScope}...`);
36
+ this.log.info(`Listing boilerplate file(s)...`);
38
37
 
39
38
  // Check if there is a .quackage-boilerplate.json in either the current directory or the user's home directory.
40
39
  let tmpCWDFilesetPath = `${this.fable.AppData.CWD}/.quackage-templates.json`;
@@ -59,7 +58,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
59
58
  if (tmpCWDFileset)
60
59
  {
61
60
  this.log.info(`...Boilerplate fileset loaded from [${tmpCWDFilesetPath}]`);
62
- this.log.info(`...Merging boilerplate fileset [${tmpCWDFilesetPath}] with [${pFileset}]`);
61
+ this.log.info(`...Merging boilerplate fileset [${tmpCWDFilesetPath}] with the base fileset`);
63
62
  this.fileSet = this.services.Utility.extend(this.fileSet, tmpCWDFileset);
64
63
  }
65
64
  }
@@ -82,7 +81,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
82
81
  if (tmpHomeFileset)
83
82
  {
84
83
  this.log.info(`...Boilerplate fileset loaded from [${tmpHomeFilesetPath}]`);
85
- this.log.info(`...Merging boilerplate fileset [${tmpHomeFilesetPath}] with [${pFileset}]`);
84
+ this.log.info(`...Merging boilerplate fileset [${tmpHomeFilesetPath}] with the base fileset`);
86
85
  this.fileSet = this.services.Utility.extend(this.fileSet, tmpHomeFileset);
87
86
  }
88
87
  }
@@ -101,10 +100,7 @@ class QuackageCommandBoilerplate extends libCommandLineCommand
101
100
  this.log.info(`${this.fable.DataFormat.stringPadEnd(tmpFileSetKeys[i], 40, ' _')} (${tmpFileSetFileCount} templated files)`);
102
101
  }
103
102
 
104
- if (typeof(fCallback) === 'function')
105
- {
106
- return fCallback();
107
- }
103
+ return fCallback();
108
104
  };
109
105
  }
110
106
 
@@ -1,5 +1,5 @@
1
+ const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
1
2
  const libFS = require('fs');
2
- const libCommandLineCommand = require('../services/Pict-Service-CommandLineCommand.js');
3
3
 
4
4
  class QuackageCommandUpdatePackage extends libCommandLineCommand
5
5
  {
@@ -10,7 +10,7 @@ class QuackageCommandUpdatePackage extends libCommandLineCommand
10
10
  this.options.CommandKeyword = 'updatepackage';
11
11
  this.options.Description = 'Update your package.json to support testing, building and luxury configurations';
12
12
 
13
- this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.fable.AppData.QuackagePackage, null, 4));
13
+ this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.pict.ProgramConfiguration, null, 4));
14
14
 
15
15
  this.options.CommandOptions.push({ Name: '-f, --force', Description: 'Force overwrite anything in the package.json; use at your own quacking peril' });
16
16
 
@@ -18,12 +18,12 @@ class QuackageCommandUpdatePackage extends libCommandLineCommand
18
18
  this.addCommand();
19
19
  }
20
20
 
21
- run(pOptions, pCommand, fCallback)
21
+ onRunAsync(fCallback)
22
22
  {
23
23
  // Execute the command
24
24
  this.log.info(`Updating package.json...`);
25
25
 
26
- let tmpOptions = pOptions;
26
+ let tmpOptions = this.CommandOptions;
27
27
 
28
28
  // The package.json from the project we are quackin at
29
29
  let tmpProjectPackage = JSON.parse(JSON.stringify(this.fable.AppData.Package));
@@ -93,10 +93,7 @@ class QuackageCommandUpdatePackage extends libCommandLineCommand
93
93
  this.log.info(`Writing ${this.fable.AppData.CWD}/package.json ...`);
94
94
  libFS.writeFileSync(`${this.fable.AppData.CWD}/package.json`, JSON.stringify(tmpProjectPackage, null, 4));
95
95
 
96
- if (typeof (fCallback) == 'function')
97
- {
98
- return fCallback();
99
- }
96
+ return fCallback();
100
97
  };
101
98
  }
102
99
 
@@ -21,11 +21,6 @@ class BaseQuackageProcessExecutionService extends libQuackageExecuteProcessBase
21
21
  return libPath.resolve(`${__dirname}/../..`);
22
22
  }
23
23
 
24
- node_modules_folder()
25
- {
26
- return libPath.resolve(`${this.quackagefolder}/..`);
27
- }
28
-
29
24
  exitParentProcess(pCode)
30
25
  {
31
26
  process.exit(pCode);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Unit tests for {~PascalCaseIdentifier:AppData.Package.name~} v.${_Package.version} {~Data:Record.Scope~}
2
+ Unit tests for {~PascalCaseIdentifier:AppData.Package.name~} v.{~D:AppData.Package.version~} {~Data:Record.Scope~}
3
3
  */
4
4
 
5
5
  const Chai = require('chai');
@@ -16,11 +16,11 @@ suite
16
16
 
17
17
  suite
18
18
  (
19
- 'Basic ${_Package.name}.v.${_Package.version} {~Data:Record.Scope~} Tests',
19
+ 'Basic {~D:_Package.name~}.v.{~D:_Package.version~} {~D:Record.Scope~} Tests',
20
20
  () =>
21
21
  {
22
22
  test(
23
- 'Object Instantiation # {~RandomNumberString:1,9~}',
23
+ 'Object Instantiation',
24
24
  (fDone) =>
25
25
  {
26
26
  let _{~PascalCaseIdentifier:AppData.Package.name~} = new lib{~PascalCaseIdentifier:AppData.Package.name~}();
@@ -4,7 +4,7 @@
4
4
  * @author Steven Velozo <steven@velozo.com>
5
5
  */
6
6
 
7
- var libQuackage = require('../source/Quackage.js');
7
+ var libQuackage = require('../source/Quackage-CLIProgram.js');
8
8
 
9
9
  var Chai = require("chai");
10
10
  var Expect = Chai.expect;
@@ -27,8 +27,8 @@ suite
27
27
  function()
28
28
  {
29
29
  // How doth the little crocodile automatically test the cli-only utility well?
30
- let testQuackage = new libQuackage();
31
- Expect(testQuackage.settings.Product).to.equal('ApplicationNameHere')
30
+ let testQuackage = libQuackage;
31
+ Expect(testQuackage.settings.Product).to.equal('Quackage')
32
32
  }
33
33
  );
34
34
  }
package/cli/quack DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const quackExecution = require('../source/Quackage.js');
@@ -1,70 +0,0 @@
1
- const libPict = require('pict');
2
-
3
- const _QuackagePackage = require('../package.json');
4
- const _QuackageDefaultConfiguration = require('./Default-Quackage-Configuration.json');
5
-
6
-
7
- let _Pict = new libPict(
8
- {
9
- Product: 'Quackage',
10
- ProductVersion: '1.0.0'
11
- }
12
- );
13
- // Instantiate the file persistence service
14
- _Pict.serviceManager.instantiateServiceProvider('FilePersistence');
15
- _Pict.serviceManager.instantiateServiceProvider('DataGeneration');
16
- // Add the Quackage Process Management service
17
- _Pict.serviceManager.addAndInstantiateServiceType('QuackageProcess', require('./services/Quackage-Execute-Process.js'));
18
- // Add the Command Line Utility service
19
- _Pict.serviceManager.addServiceType('CommandLineUtility', require('./services/Pict-Service-CommandLineUtility.js'));
20
-
21
- // Grab the current working directory for the quackage
22
- _Pict.AppData.CWD = _Pict.QuackageProcess.cwd();
23
- _Pict.AppData.QuackageFolder = _Pict.QuackageProcess.quackageFolder();
24
-
25
- // Check that a package.json is in the folder we are quacking from
26
- try
27
- {
28
- _Pict.AppData.Package = require(`${_Pict.AppData.CWD}/package.json`);
29
- }
30
- catch (pError)
31
- {
32
- _Pict.log.error(`No package.json found in [${_Pict.AppData.CWD}]. Please run quackage from a folder with a package.json file.`);
33
- _Pict.log.info(`Quack a nice day!`)
34
- _Pict.QuackageProcess.exitParentProcess(1);
35
- }
36
- finally
37
- {
38
- // Check for a quackage.json file
39
- try
40
- {
41
- _Pict.AppData.QuackagePackage = require(`${_Pict.AppData.CWD}/.quackage.json`);
42
- _Pict.AppData.QuackagePackage = _Pict.Utility.extend(_QuackageDefaultConfiguration, _Pict.AppData.QuackagePackage);
43
- }
44
- catch (pError)
45
- {
46
- _Pict.log.warn(`No ./.quackage.json found in [${_Pict.AppData.CWD}]. Using default configuration.`);
47
- _Pict.AppData.QuackagePackage = _QuackageDefaultConfiguration;
48
- }
49
-
50
- // Create our command line utility service
51
- _Pict.serviceManager.instantiateServiceProvider('CommandLineUtility',
52
- {
53
- "Command": "quackage",
54
- "Description": "CLI testing and building meant to be run from a folder with a package.json and customized with a quackage.json",
55
- "Version": _QuackagePackage.version
56
- });
57
-
58
- // Add our commands
59
- _Pict.CommandLineUtility.addCommandFromClass(require('./commands/Quackage-Command-UpdatePackage.js'));
60
- _Pict.CommandLineUtility.addCommandFromClass(require('./commands/Quackage-Command-Lint.js'));
61
- _Pict.CommandLineUtility.addCommandFromClass(require('./commands/Quackage-Command-Build.js'));
62
- _Pict.CommandLineUtility.addCommandFromClass(require('./commands/Quackage-Command-Boilerplate.js'));
63
- _Pict.CommandLineUtility.addCommandFromClass(require('./commands/Quackage-Command-BuildTemplates.js'));
64
- _Pict.CommandLineUtility.addCommandFromClass(require('./commands/Quackage-Command-ListTemplates.js'));
65
-
66
- console.log('')
67
- _Pict.CommandLineUtility.run();
68
- }
69
-
70
- module.exports = _Pict;
@@ -1,78 +0,0 @@
1
- const libPict = require('pict');
2
-
3
- const defaultCommandOptions = (
4
- {
5
- "CommandKeyword": "default",
6
- "Description": "Default command",
7
-
8
- "Aliases": [],
9
-
10
- "CommandOptions": [],
11
- "CommandArguments": []
12
- });
13
-
14
- class CommandLineCommand extends libPict.ServiceProviderBase
15
- {
16
- constructor(pFable, pOptions, pServiceHash)
17
- {
18
- // Object.assign is recursive and pollutes middle objects in some environments. UGH
19
- let tmpOptions = Object.assign({}, JSON.parse(JSON.stringify(defaultCommandOptions)), pOptions);
20
- super(pFable, tmpOptions, pServiceHash);
21
-
22
- this.serviceType = 'CommandLineCommand';
23
- }
24
-
25
- addCommand()
26
- {
27
- if (!this.options.CommandAdded)
28
- {
29
- // Find the default CommandLineUtility service, or make one if it isn't there yet
30
- let tmpCommandLineUtility = this.services.CommandLineUtility
31
- if (typeof (tmpCommandLineUtility) === 'undefined')
32
- {
33
- tmpCommandLineUtility = this.fable.ServiceManager.instantiateService('CommandLineUtility');
34
- }
35
-
36
- //_Command.command('command_keyword')
37
- // .description('The description of the command_keyword [abc] command')
38
- // Now add the command
39
- let tmpCommand = tmpCommandLineUtility.createCommand(this.options.CommandKeyword, this.options.Description);
40
- // .alias('conf')
41
- for (let i = 0; i < this.options.Aliases.length; i++)
42
- {
43
- let tmpAlias = this.options.Aliases[i];
44
- tmpCommand.alias(tmpAlias);
45
- }
46
-
47
-
48
- // .argument('[config]', 'optional hash of the configuration you want to run -- otherwise all are built', "ALL")
49
- for (let i = 0; i < this.options.CommandArguments.length; i++)
50
- {
51
- let tmpArgument = this.options.CommandArguments[i];
52
- tmpCommand.argument(tmpArgument.Name, tmpArgument.Description, tmpArgument.Default);
53
- }
54
- // .option('-f, --force', 'force')
55
- // .option('-s, --separator <char>', 'separator character', ',')
56
- for (let i = 0; i < this.options.CommandOptions.length; i++)
57
- {
58
- let tmpOption = this.options.CommandOptions[i];
59
- tmpCommand.option(tmpOption.Name, tmpOption.Description, tmpOption.Default);
60
- }
61
- // .action((pString, pOptions) => { });
62
- tmpCommand.action(this.run.bind(this));
63
- }
64
- else
65
- {
66
- this.log.error(`Command ${this.options.CommandKeyword} already added to the command line utility!`);
67
- }
68
- }
69
-
70
- run(pArgumentString, pOptions, fCallback)
71
- {
72
- // Execute the command
73
- return fCallback();
74
- };
75
-
76
- }
77
-
78
- module.exports = CommandLineCommand;
@@ -1,72 +0,0 @@
1
- const libCommander = require('commander').Command;
2
- const libPict = require('pict');
3
-
4
- const defaultCommandLineUtilityOptions = (
5
- {
6
- "Command": "default",
7
- "Description": "Default command",
8
- "Version": "0.0.0"
9
- });
10
-
11
- class CommandLineUtility extends libPict.ServiceProviderBase
12
- {
13
- constructor(pFable, pOptions, pServiceHash)
14
- {
15
- let tmpOptions = Object.assign({}, JSON.parse(JSON.stringify(defaultCommandLineUtilityOptions)), pOptions);
16
-
17
- super(pFable, tmpOptions, pServiceHash);
18
-
19
- this.serviceType = 'CommandLineUtility';
20
-
21
- // Add the CommandLineCommand service
22
- this.fable.serviceManager.addServiceType('CommandLineCommand', require('./Pict-Service-CommandLineCommand.js'));
23
-
24
- this._Command = new libCommander();
25
-
26
- this._Command.name(this.options.Command);
27
- this._Command.description(this.options.Description)
28
- this._Command.version(this.options.Version, '-v, --version', 'output the current version');
29
- }
30
-
31
- createCommand(pCommandName, pCommandDescription)
32
- {
33
- return this._Command.command(pCommandName).description(pCommandDescription);
34
- }
35
-
36
- // Just passing an options will construct one for us.
37
- // Passing a hash will set the hash.
38
- // Passing a prototype will use that!
39
- addCommand(pOptions, pHash, pPrototype)
40
- {
41
- let tmpOptions = (typeof(pOptions) == 'object') ? pOptions : {};
42
- let tmpViewHash = (typeof(pHash) == 'string') ? pHash : this.fable.getUUID();
43
-
44
- if (typeof(pPrototype) != 'undefined')
45
- {
46
- return this.fable.serviceManager.instantiateServiceProviderFromPrototype('CommandLineCommand', tmpOptions, tmpViewHash, pPrototype);
47
- }
48
- else
49
- {
50
- return this.fable.serviceManager.instantiateServiceProvider('CommandLineCommand', tmpOptions, tmpViewHash);
51
- }
52
- }
53
-
54
- // Take a prototype command and just add it as a service.
55
- addCommandFromClass(pPrototype, pHash)
56
- {
57
- let tmpHash = (typeof(pHash) == 'string') ? pHash : this.fable.getUUID();
58
- return this.fable.serviceManager.instantiateServiceProviderFromPrototype('CommandLineCommand', {}, tmpHash, pPrototype);
59
- }
60
-
61
- run ()
62
- {
63
- return this._Command.parse();
64
- }
65
-
66
- get command()
67
- {
68
- return this._Command;
69
- }
70
- }
71
-
72
- module.exports = CommandLineUtility;