spyne-cli 0.6.8 → 0.7.0

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.
Files changed (93) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +80 -30
  3. package/index.js +123 -21
  4. package/package.json +24 -6
  5. package/src/cli/args.js +197 -0
  6. package/src/cli/render.js +184 -0
  7. package/src/core/create-app.js +232 -0
  8. package/src/core/generate-module.js +146 -0
  9. package/src/registry.js +174 -0
  10. package/src/spyne-file-prompt.js +77 -30
  11. package/src/templates/generate-prompt-input-fields.js +1 -1
  12. package/src/ui.js +5 -1
  13. package/lib/ansi.js +0 -116
  14. package/lib/combos.js +0 -75
  15. package/lib/completer.js +0 -52
  16. package/lib/interpolate.js +0 -266
  17. package/lib/keypress.js +0 -243
  18. package/lib/placeholder.js +0 -63
  19. package/lib/prompt.js +0 -485
  20. package/lib/prompts/autocomplete.js +0 -113
  21. package/lib/prompts/basicauth.js +0 -41
  22. package/lib/prompts/confirm.js +0 -13
  23. package/lib/prompts/editable.js +0 -136
  24. package/lib/prompts/form.js +0 -196
  25. package/lib/prompts/index.js +0 -28
  26. package/lib/prompts/input.js +0 -55
  27. package/lib/prompts/invisible.js +0 -11
  28. package/lib/prompts/list.js +0 -36
  29. package/lib/prompts/multiselect.js +0 -11
  30. package/lib/prompts/numeral.js +0 -1
  31. package/lib/prompts/password.js +0 -18
  32. package/lib/prompts/quiz.js +0 -37
  33. package/lib/prompts/scale.js +0 -237
  34. package/lib/prompts/select.js +0 -139
  35. package/lib/prompts/snippet.js +0 -185
  36. package/lib/prompts/sort.js +0 -37
  37. package/lib/prompts/survey.js +0 -163
  38. package/lib/prompts/text.js +0 -1
  39. package/lib/prompts/toggle.js +0 -109
  40. package/lib/render.js +0 -33
  41. package/lib/roles.js +0 -46
  42. package/lib/state.js +0 -69
  43. package/lib/styles.js +0 -144
  44. package/lib/symbols.js +0 -66
  45. package/lib/theme.js +0 -11
  46. package/lib/timer.js +0 -38
  47. package/lib/types/array.js +0 -658
  48. package/lib/types/auth.js +0 -29
  49. package/lib/types/boolean.js +0 -88
  50. package/lib/types/index.js +0 -7
  51. package/lib/types/number.js +0 -86
  52. package/lib/types/string.js +0 -185
  53. package/lib/utils.js +0 -268
  54. package/mocha.conf.cjs +0 -16
  55. package/src/app/channels/.gitkeep +0 -0
  56. package/src/app/channels/channel-custom.js +0 -1
  57. package/src/app/components/.gitkeep +0 -0
  58. package/src/app/traits/.gitkeep +0 -0
  59. package/src/hello-world-app-source/README.md +0 -15
  60. package/src/hello-world-app-source/apache-htaccess +0 -20
  61. package/src/hello-world-app-source/karma.conf.js +0 -75
  62. package/src/hello-world-app-source/package.json +0 -50
  63. package/src/hello-world-app-source/src/app/app-view.js +0 -38
  64. package/src/hello-world-app-source/src/app/channels/.gitkeep +0 -0
  65. package/src/hello-world-app-source/src/app/components/.gitkeep +0 -0
  66. package/src/hello-world-app-source/src/app/traits/.gitkeep +0 -0
  67. package/src/hello-world-app-source/src/index.js +0 -16
  68. package/src/hello-world-app-source/src/index.tmpl.html +0 -12
  69. package/src/hello-world-app-source/src/scss/01-vendors/normalize.css +0 -349
  70. package/src/hello-world-app-source/src/scss/02-variables/mixins.scss +0 -0
  71. package/src/hello-world-app-source/src/scss/03-components/.gitkeep +0 -0
  72. package/src/hello-world-app-source/src/scss/main.scss +0 -15
  73. package/src/hello-world-app-source/src/static/data/.gitkeep +0 -0
  74. package/src/hello-world-app-source/src/static/fonts/.gitkeep +0 -0
  75. package/src/hello-world-app-source/src/static/imgs/.gitkeep +0 -0
  76. package/src/hello-world-app-source/src/tests/unit-tests/index.test.js +0 -10
  77. package/src/hello-world-app-source/webpack.config.js +0 -178
  78. package/src/spyne-app-create.js +0 -209
  79. package/src/spyne-app-creator.js +0 -119
  80. package/src/spyne-starter-app-create.js +0 -147
  81. package/tests/create-spyne-app.test.js +0 -63
  82. package/tests/generate-file-prompt.test.js +0 -45
  83. package/tests/generate-file-string.test.js +0 -66
  84. package/tests/generate-prompt-input-fields-methods.test.js +0 -177
  85. package/tests/generate-prompt-input-fields.test.js +0 -179
  86. package/tests/generate-prompt-input-object.test.js +0 -39
  87. package/tests/generate-prompt-output.test.js +0 -58
  88. package/tests/index.test.js +0 -11
  89. package/tests/mocks/answers.js +0 -33
  90. package/tests/mocks/answers.json +0 -33
  91. package/tests/mocks/enquirer-data.js +0 -411
  92. package/tests/mocks/enquirer-data.json +0 -409
  93. package/tests/utils/file-utils.test.js +0 -84
@@ -1,63 +0,0 @@
1
- import {expect} from 'chai';
2
- import path from 'path';
3
-
4
- import SpyneAppCreator from '../src/spyne-app-creator.js';
5
-
6
- const appArgsFalseArr = [ '/usr/local/bin/node', '/usr/local/bin/spyne-cli', 'create-app'];
7
- const appArgsTrueArr = [ '/usr/local/bin/node', '/usr/local/bin/spyne-cli', 'create-app', 'myapp'];
8
-
9
-
10
- describe('should test app creation methods', () => {
11
-
12
- it('should run create app false', () => {
13
- let {createAppBool, folderName} = SpyneAppCreator.checkArgs(appArgsFalseArr);
14
- expect(createAppBool).to.be.true;
15
- expect(folderName).to.eq(undefined);
16
- });
17
-
18
- it('should run create app true', () => {
19
- let {createAppBool, folderName} = SpyneAppCreator.checkArgs(appArgsTrueArr);
20
- expect(createAppBool).to.be.true;
21
- expect(folderName).to.eq('myapp');
22
- });
23
-
24
- it('should return directory exists bool true', ()=>{
25
- let folderName = 'utils';
26
- let currentPath = path.resolve('./src');
27
- const appDir = `${currentPath}/${folderName}`;
28
- const dirAlreadyExistsBool = SpyneAppCreator.checkIfDirectoryExists(appDir);
29
- expect(dirAlreadyExistsBool).to.equal(true);
30
- })
31
-
32
- it('should return directory exists bool false', ()=>{
33
- let folderName = 'dir-does-not-exist';
34
- let currentPath = path.resolve('./src');
35
- const appDir = `${currentPath}/${folderName}`;
36
- const dirAlreadyExistsBool = SpyneAppCreator.checkIfDirectoryExists(appDir);
37
- expect(dirAlreadyExistsBool).to.equal(false);
38
-
39
- })
40
-
41
- it('should return folder name is undefined error', ()=>{
42
- const appPath = path.resolve('./src');
43
- const errorCheck = SpyneAppCreator.checkForErrors(appPath);
44
- const folderNameMissingErrCheck = String(errorCheck).indexOf('Please add a folder name!')>=1;
45
- expect(folderNameMissingErrCheck).to.be.true;
46
- })
47
-
48
- it('should return app folder already exists error', ()=>{
49
-
50
- const folder = 'h-world-new';
51
- const appPath = path.resolve('./src');
52
- const appSrc = `${appPath}/hello-world-app-source`
53
- const appDest = `${appPath}/${folder}`
54
- const errorCheck = SpyneAppCreator.checkForErrors(appPath, folder);
55
- const hasAppExistsErr = String(errorCheck).indexOf("App folder already exists!")>=1;
56
- expect(hasAppExistsErr).to.be.true;
57
-
58
- })
59
-
60
-
61
-
62
-
63
- });
@@ -1,45 +0,0 @@
1
- import SpyneFilePrompt from '../src/spyne-file-prompt.js';
2
- import {expect, assert} from 'chai';
3
-
4
-
5
- describe('should test spyne file prompt', () => {
6
-
7
- const spyneFilePrompt = new SpyneFilePrompt();
8
-
9
- it('SpyneFilePrompt should exist', () => {
10
- expect(SpyneFilePrompt).to.exist;
11
-
12
- });
13
-
14
-
15
- it('should get the initial select prompt ',()=>{
16
-
17
- const selectPrompt = spyneFilePrompt.getSelectPromptObj();
18
-
19
- //console.log('spyne file prompt is ',{selectPrompt})
20
-
21
- expect(selectPrompt.type).to.equal('Select');
22
- expect(selectPrompt).to.be.an('object');
23
-
24
- })
25
-
26
- it('should get file type obj from json data',()=>{
27
-
28
- const fileType = 'ViewStream';
29
- const viewStreamObj = SpyneFilePrompt.getFilePromptPropertiesObj(fileType);
30
- expect(viewStreamObj.props).to.deep.equal([ 'fileName', 'className', 'fileDirectory' ])
31
-
32
- })
33
-
34
- it('should get prompt array from file type', ()=>{
35
- const fileType = 'Channel';
36
- const promptArr = SpyneFilePrompt.getFilePrompt(fileType);
37
-
38
- //console.log('prompt arr is ',{promptArr})
39
-
40
- return true;
41
-
42
- })
43
-
44
-
45
- });
@@ -1,66 +0,0 @@
1
- import {expect, assert} from 'chai';import GenerateFileString from '../src/templates/generate-file-string.js';
2
-
3
- describe('should test file string generator', () => {
4
-
5
- it('file string generator should exist', () => {
6
-
7
- expect(GenerateFileString).to.exist;
8
-
9
- });
10
-
11
- it('should generate string for ViewStream file', ()=>{
12
- const props = {
13
- fileName: 'my-viewstream-file.js',
14
- className: 'MyViewstreamClass'
15
- }
16
- const fileStrGen = new GenerateFileString('ViewStream', props);
17
- const fileString = fileStrGen.fileString;
18
- const classNameAdded = fileString.indexOf('class MyViewstreamClass ') >= 0;
19
- // console.log('view stream file str is ',{classNameAdded}, fileString)
20
- expect(classNameAdded).to.be.true;
21
- });
22
-
23
- it('should generate string for DomElement file', ()=>{
24
- const props = {
25
- fileName: 'my-dom-element-file.js',
26
- className: 'MyDomElementClass'
27
- }
28
- const fileStrGen = new GenerateFileString('DomElement', props);
29
- const fileString = fileStrGen.fileString;
30
- const classNameAdded = fileString.indexOf('class MyDomElementClass ') >= 0;
31
- //console.log('DomElement file str is ',{classNameAdded}, fileString)
32
- expect(classNameAdded).to.be.true;
33
- });
34
-
35
-
36
- it('should generate string for Channel file', ()=>{
37
- const props = {
38
- fileName: 'my-channel-file.js',
39
- className: 'MyChannelClass',
40
- channelName: 'MY_CUSTOM_CHANNEL',
41
- replayLastPayload: true
42
- }
43
- const fileStrGen = new GenerateFileString('Channel', props);
44
- const fileString = fileStrGen.fileString;
45
- const classNameAdded = fileString.indexOf('class MyChannelClass ') >= 0;
46
- //console.log('channel file str is ',{classNameAdded}, fileString)
47
- expect(classNameAdded).to.be.true;
48
- });
49
-
50
-
51
- it('should generate string for SpyneTrait file', ()=>{
52
- const props = {
53
- fileName: 'my-spynetrait-file.js',
54
- className: 'MySpyneTrait',
55
- methodPrefix: 'myTrait$'
56
- }
57
- const fileStrGen = new GenerateFileString('SpyneTrait', props);
58
- const fileString = fileStrGen.fileString;
59
- const classNameAdded = fileString.indexOf('class MySpyneTrait ') >= 0;
60
- //console.log('channel file str is ',{classNameAdded}, fileString)
61
- expect(classNameAdded).to.be.true;
62
-
63
- });
64
-
65
-
66
- });
@@ -1,177 +0,0 @@
1
- import {expect, assert} from 'chai';import PromptInputField from '../src/templates/generate-prompt-input-fields.js';
2
- import * as changeCase from "change-case";
3
-
4
- const {
5
- camelCase,
6
- capitalCase,
7
- constantCase,
8
- dotCase,
9
- headerCase,
10
- noCase,
11
- paramCase,
12
- pascalCase,
13
- pathCase,
14
- sentenceCase,
15
- snakeCase,
16
- } = changeCase;
17
-
18
-
19
- import {MockData} from './mocks/enquirer-data.js';
20
-
21
-
22
-
23
- describe('should create all necessary prompt input initial, hint and validate fields', () => {
24
-
25
- it('PromptInputField should exist', () => {
26
- expect(PromptInputField).to.exist;
27
- });
28
-
29
-
30
- describe('it should generate all initial values ',()=>{
31
-
32
- let inputType = "className";
33
- let fileType = "ViewStream";
34
-
35
- it('should generate initial file name values ',()=>{
36
- const fileNameInputType = "fileName"
37
- let fieldType = "initial";
38
-
39
- const viewStreamInitialValue = new PromptInputField(fileNameInputType, 'ViewStream', fieldType).field;
40
- const domElementInitialValue = new PromptInputField(fileNameInputType, 'DomElement', fieldType).field;
41
- const channelInitialValue = new PromptInputField(fileNameInputType, 'Channel', fieldType).field;
42
- const spyneTraitInitialValue = new PromptInputField(fileNameInputType, 'SpyneTrait', fieldType).field;
43
-
44
- const isValidFileName = (str)=>/(.*)(.js)/.test(str)===true;
45
-
46
- /*console.log('view stream file name is ',{viewStreamInitialValue})
47
- console.log('dom element file name is ',{domElementInitialValue})
48
- console.log('channel file name is ',{channelInitialValue})
49
- console.log('spyne trait file name is ',{spyneTraitInitialValue})
50
- */
51
-
52
-
53
- expect(isValidFileName(viewStreamInitialValue)).to.be.true;
54
- expect(isValidFileName(domElementInitialValue)).to.be.true;
55
- expect(isValidFileName(channelInitialValue)).to.be.true;
56
- expect(isValidFileName(spyneTraitInitialValue)).to.be.true;
57
-
58
- })
59
-
60
-
61
- it('should generate initial value for className based on valid filename', ()=>{
62
- MockData.enquirer.answers.fileName = 'my-viewstream.js';
63
-
64
- const initialViewStreamClassNameFn = new PromptInputField(inputType, fileType, 'initial').field;
65
- const initialViewStreamClassName = initialViewStreamClassNameFn(MockData);
66
-
67
- MockData.enquirer.answers.fileName = 'my-dom-element.js';
68
- const initialDomElementClassNameFn = new PromptInputField(inputType, fileType, 'initial').field;
69
- const initialDomElementClassName = initialDomElementClassNameFn(MockData);
70
-
71
- MockData.enquirer.answers.fileName = 'channel-custom.js';
72
- const initialChannelClassNameFn = new PromptInputField(inputType, fileType, 'initial').field;
73
- const initialChannelClassName = initialDomElementClassNameFn(MockData);
74
-
75
- MockData.enquirer.answers.fileName = 'my-custom-trait.js';
76
- const initialTraitClassNameFn = new PromptInputField(inputType, fileType, 'initial').field;
77
- const initialTraitClassName = initialTraitClassNameFn(MockData);
78
-
79
-
80
- /* console.log('initial class name is ',{initialViewStreamClassName})
81
- console.log('initial dom element is ',{initialDomElementClassName})
82
- console.log('initial channel is ',{initialChannelClassName})
83
- console.log('initial trait is ',{initialTraitClassName})*/
84
-
85
- expect(initialViewStreamClassName).to.equal('MyViewstream')
86
- expect(initialDomElementClassName).to.equal('MyDomElement')
87
- expect(initialChannelClassName).to.equal('ChannelCustom')
88
- expect(initialTraitClassName).to.equal('MyCustomTrait')
89
-
90
-
91
- })
92
-
93
-
94
- it('it should generate initial value for directory based on app path', ()=>{
95
- let inputType = 'fileDirectory';
96
- const initialViewStreamFileDir = new PromptInputField(inputType, fileType, 'initial').field;
97
- const initialDomElementFileDir = new PromptInputField(inputType, 'DomElement', 'initial').field;
98
- const initialChannelFileDir = new PromptInputField(inputType, 'Channel', 'initial').field;
99
- const initialSpyneTraitFileDir = new PromptInputField(inputType, 'SpyneTrait', 'initial').field;
100
- //console.log('viewstream dir ',{initialViewStreamFileDir})
101
- //console.log('domelement dir ',{initialDomElementFileDir})
102
- //console.log('channel dir ',{initialChannelFileDir})
103
- //console.log('spynetrait dir ',{initialSpyneTraitFileDir})
104
-
105
-
106
-
107
- //console.log('process ',{initialFileDir})
108
-
109
- expect(initialViewStreamFileDir).to.equal('./src/app/components/')
110
- expect(initialDomElementFileDir).to.equal('./src/app/components/')
111
- expect(initialChannelFileDir).to.equal('./src/app/channels/')
112
- expect(initialSpyneTraitFileDir).to.equal('./src/app/traits/')
113
-
114
- })
115
-
116
- it('it should generate initial value for method prefix', ()=>{
117
- MockData.enquirer.answers.className = 'MyCustomTrait';
118
- fileType = "SpyneTrait";
119
- inputType = "methodPrefix";
120
- const initialMethodPrefixFn = new PromptInputField(inputType, fileType, 'initial').field;
121
- const initialMethodPrefix = initialMethodPrefixFn(MockData);
122
- expect(initialMethodPrefix).to.equal('myCustom$')
123
-
124
-
125
- })
126
-
127
- it('it should generate initial value for channel name', ()=>{
128
- MockData.enquirer.answers.className = 'ChannelCustom';
129
- fileType = "Channel";
130
- inputType = "channelName";
131
- const initialMethodPrefixFn = new PromptInputField(inputType, fileType, 'initial').field;
132
- const initialMethodPrefix = initialMethodPrefixFn(MockData);
133
-
134
- //console.log('channel name is ',initialMethodPrefix);
135
- expect(initialMethodPrefix).to.equal('CHANNEL_CUSTOM')
136
-
137
- })
138
-
139
-
140
-
141
-
142
-
143
-
144
- })
145
-
146
-
147
- describe('it should add proper validator for field',()=>{
148
- const fieldType = 'validate';
149
-
150
- it ('should generate validator for fileName ', ()=>{
151
- const fileNameValidatorFn = new PromptInputField("fileName", "ViewStream", fieldType).field;
152
- const fileNameValidator = fileNameValidatorFn('my-custom-viewstream.js');
153
- //console.log('file name validator is ',{fileNameValidator})
154
- expect(fileNameValidator).to.be.true;
155
-
156
- })
157
-
158
- it ('should generate validator for file directory', ()=>{
159
- const fileDirectoryValidatorFn = new PromptInputField("fileDirectory", "ViewStream", fieldType).field;
160
- const validPath = './src/app/components/'
161
- const inValidPath = './src/stuff'
162
- const isValidDir = fileDirectoryValidatorFn(validPath);
163
- const isInvalidDir = fileDirectoryValidatorFn(inValidPath);
164
- expect(isValidDir).to.be.true;
165
- expect(isInvalidDir).to.equal("File directory needs to exist.")
166
-
167
- })
168
-
169
-
170
-
171
- })
172
-
173
-
174
-
175
-
176
-
177
- });
@@ -1,179 +0,0 @@
1
- import {expect, assert} from 'chai';import PromptInputField from '../src/templates/generate-prompt-input-fields.js';
2
-
3
- import {MockData} from './mocks/enquirer-data.js';
4
-
5
- const sani = (str)=>{
6
- const len = String(str).length;
7
- //String(str).replace(/^(\\.+\d{2}\w)(Enter.*name)(\\.*)$/, "$2")
8
- return String(str).substr(5, len-10);
9
- }
10
-
11
-
12
- describe('should create all necessary prompt input fields', () => {
13
-
14
- it('PromptInputField should exist', () => {
15
- expect(PromptInputField).to.exist;
16
- });
17
-
18
-
19
-
20
- describe('should generate basic input fields', ()=>{
21
- let inputType = "fileName";
22
- let fileType = "ViewStream";
23
-
24
- it('should generate type field', ()=>{
25
- const fieldType = 'type';
26
- const type = new PromptInputField(inputType, fileType, fieldType).field;
27
- //console.log('type is ',{type})
28
- expect(type).to.equal('input');
29
- })
30
-
31
-
32
- it('should generate name field', ()=>{
33
- const fieldType = "name";
34
- const name = new PromptInputField(inputType, fileType, fieldType).field;
35
- expect(name).to.equal(inputType);
36
-
37
- })
38
-
39
- it('should generate input format ',()=>{
40
- const fieldType = 'format';
41
- const format = new PromptInputField(inputType, fileType, fieldType).field;
42
- //console.log('format is ',{format}, format('colored output'))
43
- expect(format).to.be.an('function');
44
- })
45
-
46
- it('should parse input and remove color',()=>{
47
- const fieldType = 'result';
48
- const format = new PromptInputField(inputType, fileType, 'format').field;
49
- const result = new PromptInputField(inputType, fileType, fieldType).field;
50
- const formatStr = format('foo');
51
- const parsedFormatStr = result(formatStr);
52
- //console.log('field is ',{format,result, formatStr, parsedFormatStr})
53
- expect(parsedFormatStr).to.equal('foo');
54
-
55
- })
56
-
57
- it('should generate choices for selectFileType ',()=>{
58
- const fieldType = 'choices';
59
- const format = new PromptInputField('selectFileType', 'Channel', fieldType).field;
60
- const result = new PromptInputField(inputType, fileType, 'result').field;
61
-
62
- expect(result(format)).to.equal("ViewStream,DomElement,Channel,SpyneTrait");
63
- })
64
-
65
- })
66
-
67
- describe('it should generate input messages for each input and file types ',()=>{
68
- const fieldType = "message";
69
-
70
-
71
- it('should generate messages for filename ',()=>{
72
- const inputType = 'fileName';
73
-
74
-
75
- const expectedStr = (_fileType)=>`Enter the ${_fileType} file name`
76
-
77
- const viewsStreamMsg = new PromptInputField(inputType, 'ViewStream', fieldType).field;
78
- const domElementMsg = new PromptInputField(inputType, 'DomElement', fieldType).field;
79
- const channelMsg = new PromptInputField(inputType, 'Channel', fieldType).field;
80
- const spyneTraitMsg = new PromptInputField(inputType, 'SpyneTrait', fieldType).field;
81
-
82
-
83
- /* console.log('view stream msg is ', sani(viewsStreamMsg))
84
- console.log('view stream msg is ',{domElementMsg})
85
- console.log('view stream msg is ',{channelMsg})
86
- console.log('view stream msg is ',{spyneTraitMsg})
87
- */
88
- expect(sani(viewsStreamMsg)).to.equal(expectedStr('ViewStream'))
89
- expect(sani(domElementMsg)).to.equal(expectedStr('DomElement'))
90
- expect(sani(channelMsg)).to.equal(expectedStr('Channel'))
91
- expect(sani(spyneTraitMsg)).to.equal(expectedStr('SpyneTrait'))
92
- })
93
-
94
-
95
-
96
-
97
- it('should generate messages for className', ()=>{
98
- const inputType = 'className';
99
- const expectedStr = (_fileType)=>`Enter the ${_fileType} class name`
100
-
101
- const viewsStreamMsg = new PromptInputField(inputType, 'ViewStream', fieldType).field;
102
- const domElementMsg = new PromptInputField(inputType, 'DomElement', fieldType).field;
103
- const channelMsg = new PromptInputField(inputType, 'Channel', fieldType).field;
104
- const spyneTraitMsg = new PromptInputField(inputType, 'SpyneTrait', fieldType).field;
105
-
106
- /* console.log('view stream msg is ',sani(viewsStreamMsg))
107
- console.log('view stream msg is ',{domElementMsg})
108
- console.log('view stream msg is ',{channelMsg})
109
- console.log('view stream msg is ',{spyneTraitMsg})*/
110
-
111
- expect(sani(viewsStreamMsg)).to.equal(expectedStr('ViewStream'))
112
- expect(sani(domElementMsg)).to.equal(expectedStr('DomElement'))
113
- expect(sani(channelMsg)).to.equal(expectedStr('Channel'))
114
- expect(sani(spyneTraitMsg)).to.equal(expectedStr('SpyneTrait'))
115
-
116
- return true;
117
-
118
- })
119
-
120
- it('should generate messages for fileDirectory', ()=>{
121
- const inputType = 'fileDirectory';
122
- const expectedStr = (_fileType)=>`Enter where you would like to save the ${_fileType} file`
123
-
124
- const viewsStreamMsg = new PromptInputField(inputType, 'ViewStream', fieldType).field;
125
- const domElementMsg = new PromptInputField(inputType, 'DomElement', fieldType).field;
126
- const channelMsg = new PromptInputField(inputType, 'Channel', fieldType).field;
127
- const spyneTraitMsg = new PromptInputField(inputType, 'SpyneTrait', fieldType).field;
128
-
129
- /* console.log('view stream msg is ',{viewsStreamMsg})
130
- console.log('view stream msg is ',{domElementMsg})
131
- console.log('view stream msg is ',{channelMsg})
132
- console.log('view stream msg is ',{spyneTraitMsg})*/
133
-
134
- expect(sani(viewsStreamMsg)).to.equal(expectedStr('ViewStream'))
135
- expect(sani(domElementMsg)).to.equal(expectedStr('DomElement'))
136
- expect(sani(channelMsg)).to.equal(expectedStr('Channel'))
137
- expect(sani(spyneTraitMsg)).to.equal(expectedStr('SpyneTrait'))
138
-
139
- return true;
140
-
141
- })
142
-
143
- it('should generate message for channelName', ()=>{
144
- MockData.enquirer.answers.className="MyChannel"
145
- const inputType = 'channelName';
146
- const expectedStr = `Enter the channel name for MyChannel`
147
- const channelNameMsgFn = new PromptInputField(inputType, 'SpyneTrait', fieldType).field;
148
- const channelNameMsg = channelNameMsgFn(MockData.enquirer);
149
- //console.log('channelNameMsg stream msg is ',{channelNameMsg}, channelNameMsg(MockData))
150
- expect(sani(channelNameMsg)).to.equal(expectedStr)
151
- return true;
152
-
153
- })
154
-
155
-
156
- it('should generate message for methodPrefix$', ()=>{
157
- const inputType = 'methodPrefix';
158
- const expectedStr = `Enter the string to be prepended to all trait methods`
159
- const spyneTraitMethodPrefix = new PromptInputField(inputType, 'SpyneTrait', fieldType).field;
160
- //console.log('view stream msg is ',{spyneTraitMethodPrefix})
161
- expect(sani(spyneTraitMethodPrefix)).to.equal(expectedStr)
162
-
163
- })
164
-
165
- it('should generate message for replayLastPayload', ()=>{
166
- const inputType = 'replayLastPayload';
167
- const expectedStr = `This property determines if new subscribers receive the previous payload`
168
- const replayLastPayloadMsg = new PromptInputField(inputType, 'Channel', fieldType).field;
169
- //console.log('view stream msg is ',{replayLastPayloadMsg})
170
- expect(sani(replayLastPayloadMsg)).to.equal(expectedStr)
171
- //return true;
172
- })
173
-
174
-
175
-
176
-
177
- })
178
-
179
- });
@@ -1,39 +0,0 @@
1
- import {expect, assert} from 'chai';import GeneratePromptInputObject from '../src/templates/generate-prompt-input-object.js';
2
- import {Data} from '../src/spyne-template-prompts.js';
3
- import {MockData} from './mocks/enquirer-data.js';
4
- const {promptTypes} = Data;
5
-
6
- describe('should test prompt input object generator', () => {
7
-
8
- it('input prompt generator should exist', () => {
9
- expect(GeneratePromptInputObject).to.exist;
10
-
11
- });
12
-
13
-
14
- it('should get initial select file prompt object', ()=>{
15
- const inputType = 'selectFileType';
16
- const inputPrompt = new GeneratePromptInputObject(inputType);
17
- //console.log('input prompt is ',{inputPrompt}, inputPrompt.getPrompObject())
18
- const prompt = inputPrompt.getPrompObject();
19
-
20
- expect(prompt).to.be.an('object');
21
-
22
-
23
- })
24
-
25
- it('should generate ViewStream fileName input', ()=>{
26
- const inputType = 'fileName';
27
- const fileType = 'ViewStream';
28
-
29
- const inputPrompt = new GeneratePromptInputObject(inputType, fileType);
30
-
31
-
32
- //console.log('input prompt is ',inputPrompt.getPrompObject());
33
-
34
- return true;
35
-
36
- })
37
-
38
-
39
- });
@@ -1,58 +0,0 @@
1
- import {expect, assert} from 'chai';import {MockData} from './mocks/enquirer-data.js';
2
- import {AnswersData} from './mocks/answers.js';
3
- const {answersArr} = AnswersData;
4
- import {generatePromptOutput} from '../src/templates/generate-prompt-output.js';
5
- import * as R from 'ramda';
6
-
7
- const getAnswersByFileType = (fileType) => R.compose(R.head, R.filter(R.propEq(fileType, 'fileType')))(answersArr)
8
-
9
- const defaultStr = `
10
- import {Subject} from 'rxjs';
11
- import {Channel, ChannelPayloadFilter} from 'spyne';
12
-
13
-
14
- export class ChannelCustom extends Channel{
15
-
16
- constructor(name, props={}) {
17
- name="CHANNEL_CUSTOM";
18
- props.replayLastPayload = true;
19
- super(name, props);
20
-
21
- }
22
-
23
- onRegistered(){
24
-
25
- }
26
-
27
- addRegisteredActions() {
28
- return [];
29
- }
30
-
31
- onViewStreamInfo(obj) {
32
- let data = obj.props();
33
- }
34
-
35
-
36
-
37
- }
38
-
39
- `
40
-
41
-
42
-
43
- describe('should test saving to file', () => {
44
- it('should save file', () => {
45
- const answersObj = getAnswersByFileType('Channel');
46
- const {fileName, fileDirectory} = answersObj;
47
-
48
- const fileHasSaved = false;
49
- const fileExists = false;
50
- const savedProps = {fileHasSaved, fileExists};
51
-
52
- const msgOutput = generatePromptOutput(answersObj, savedProps, defaultStr);
53
-
54
- expect(msgOutput).to.be.a('string');
55
-
56
- });
57
-
58
- });
@@ -1,11 +0,0 @@
1
- import {expect, assert} from 'chai';
2
- describe('should test cli methods', () => {
3
-
4
- it('should run cli tests', () => {
5
-
6
-
7
- return true;
8
-
9
- });
10
-
11
- });
@@ -1,33 +0,0 @@
1
- const AnswersData = {
2
- "answersArr": [
3
- {
4
- "fileName": "my-ui-el-view.js",
5
- "className": "MyUiElView",
6
- "fileDirectory": "./src/app/components/",
7
- "fileType": "ViewStream"
8
- },
9
- {
10
- "fileName": "my-dom-element.js",
11
- "className": "MyDomElement",
12
- "fileDirectory": "./src/app/components/",
13
- "fileType": "DomElement"
14
- },
15
- {
16
- "fileName": "channel-custom.js",
17
- "className": "ChannelCustom",
18
- "channelName": "CHANNEL_CUSTOM",
19
- "replayLastPayload": false,
20
- "fileDirectory": "./src/app/channels/",
21
- "fileType": "Channel"
22
- },
23
- {
24
- "fileName": "my-custom-trait.js",
25
- "className": "MyCustomTrait",
26
- "methodPrefix": "myCustom$",
27
- "fileDirectory": "./src/app/traits/",
28
- "fileType": "SpyneTrait"
29
- }
30
- ]
31
- }
32
-
33
- export {AnswersData}