@tremho/mist-lift 1.0.2-pre-release.4 → 1.0.2

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 (107) hide show
  1. package/README.md +12 -0
  2. package/build/commands/actions/initQuestions.js +24 -22
  3. package/build/commands/actions/initQuestions.js.map +1 -1
  4. package/build/commands/actions/setupPackageJson.js +4 -4
  5. package/build/commands/actions/setupPackageJson.js.map +1 -1
  6. package/build/commands/build.js +31 -25
  7. package/build/commands/build.js.map +1 -1
  8. package/build/commands/builtin/ApiDocMaker.js +60 -23
  9. package/build/commands/builtin/ApiDocMaker.js.map +1 -1
  10. package/build/commands/builtin/BuiltInHandler.js +6 -6
  11. package/build/commands/builtin/BuiltInHandler.js.map +1 -1
  12. package/build/commands/builtin/DeployBuiltInZip.js +4 -4
  13. package/build/commands/builtin/DeployBuiltInZip.js.map +1 -1
  14. package/build/commands/builtin/StageWebrootZip.js +1 -0
  15. package/build/commands/builtin/StageWebrootZip.js.map +1 -1
  16. package/build/commands/create.js +10 -11
  17. package/build/commands/create.js.map +1 -1
  18. package/build/commands/deploy.js +38 -42
  19. package/build/commands/deploy.js.map +1 -1
  20. package/build/commands/doctor.js +38 -37
  21. package/build/commands/doctor.js.map +1 -1
  22. package/build/commands/help.js +93 -93
  23. package/build/commands/help.js.map +1 -1
  24. package/build/commands/init.js +7 -7
  25. package/build/commands/init.js.map +1 -1
  26. package/build/commands/package.js +50 -51
  27. package/build/commands/package.js.map +1 -1
  28. package/build/commands/publish.js +98 -102
  29. package/build/commands/publish.js.map +1 -1
  30. package/build/commands/settings.js +19 -18
  31. package/build/commands/settings.js.map +1 -1
  32. package/build/commands/start.js +4 -4
  33. package/build/commands/start.js.map +1 -1
  34. package/build/commands/test.js +3 -3
  35. package/build/commands/test.js.map +1 -1
  36. package/build/commands/user.js +1 -1
  37. package/build/commands/user.js.map +1 -1
  38. package/build/expressRoutes/all.js +27 -26
  39. package/build/expressRoutes/all.js.map +1 -1
  40. package/build/expressRoutes/api.js +9 -7
  41. package/build/expressRoutes/api.js.map +1 -1
  42. package/build/expressRoutes/functionBinder.js +38 -36
  43. package/build/expressRoutes/functionBinder.js.map +1 -1
  44. package/build/lib/CaseUtils.js +2 -2
  45. package/build/lib/CaseUtils.js.map +1 -1
  46. package/build/lib/DirectoryUtils.js +4 -3
  47. package/build/lib/DirectoryUtils.js.map +1 -1
  48. package/build/lib/LiftConfig.js +18 -20
  49. package/build/lib/LiftConfig.js.map +1 -1
  50. package/build/lib/LiftVersion.js +17 -12
  51. package/build/lib/LiftVersion.js.map +1 -1
  52. package/build/lib/Tests/fileCompare.test.js +11 -10
  53. package/build/lib/Tests/fileCompare.test.js.map +1 -1
  54. package/build/lib/askQuestion.js +3 -2
  55. package/build/lib/askQuestion.js.map +1 -1
  56. package/build/lib/executeCommand.js +46 -33
  57. package/build/lib/executeCommand.js.map +1 -1
  58. package/build/lib/fileCompare.js +9 -8
  59. package/build/lib/fileCompare.js.map +1 -1
  60. package/build/lib/openAPI/ApiBuildCollector.js +9 -8
  61. package/build/lib/openAPI/ApiBuildCollector.js.map +1 -1
  62. package/build/lib/openAPI/WebrootFileSupport.js +4 -3
  63. package/build/lib/openAPI/WebrootFileSupport.js.map +1 -1
  64. package/build/lib/openAPI/openApiConstruction.js +62 -61
  65. package/build/lib/openAPI/openApiConstruction.js.map +1 -1
  66. package/build/lib/pathResolve.js +4 -4
  67. package/build/lib/pathResolve.js.map +1 -1
  68. package/build/lib/utils.js +5 -4
  69. package/build/lib/utils.js.map +1 -1
  70. package/build/lift.js +14 -15
  71. package/build/lift.js.map +1 -1
  72. package/package.json +2 -1
  73. package/src/commands/actions/initQuestions.ts +112 -112
  74. package/src/commands/actions/setupPackageJson.ts +21 -25
  75. package/src/commands/build.ts +143 -146
  76. package/src/commands/builtin/ApiDocMaker.ts +86 -54
  77. package/src/commands/builtin/BuiltInHandler.ts +31 -35
  78. package/src/commands/builtin/DeployBuiltInZip.ts +15 -17
  79. package/src/commands/builtin/StageWebrootZip.ts +29 -32
  80. package/src/commands/create.ts +40 -47
  81. package/src/commands/deploy.ts +139 -152
  82. package/src/commands/doctor.ts +86 -82
  83. package/src/commands/help.ts +152 -153
  84. package/src/commands/init.ts +37 -39
  85. package/src/commands/package.ts +201 -204
  86. package/src/commands/publish.ts +277 -312
  87. package/src/commands/settings.ts +67 -70
  88. package/src/commands/start.ts +32 -37
  89. package/src/commands/test.ts +15 -16
  90. package/src/commands/user.ts +1 -1
  91. package/src/expressRoutes/all.ts +73 -78
  92. package/src/expressRoutes/api.ts +14 -16
  93. package/src/expressRoutes/functionBinder.ts +144 -151
  94. package/src/lib/CaseUtils.ts +49 -54
  95. package/src/lib/DirectoryUtils.ts +25 -27
  96. package/src/lib/LiftConfig.ts +46 -54
  97. package/src/lib/LiftVersion.ts +69 -77
  98. package/src/lib/Tests/fileCompare.test.ts +27 -26
  99. package/src/lib/askQuestion.ts +12 -13
  100. package/src/lib/executeCommand.ts +40 -33
  101. package/src/lib/fileCompare.ts +46 -37
  102. package/src/lib/openAPI/ApiBuildCollector.ts +36 -36
  103. package/src/lib/openAPI/WebrootFileSupport.ts +15 -17
  104. package/src/lib/openAPI/openApiConstruction.ts +169 -175
  105. package/src/lib/pathResolve.ts +22 -28
  106. package/src/lib/utils.ts +31 -33
  107. package/src/lift.ts +68 -67
@@ -1,171 +1,170 @@
1
1
  import * as ac from 'ansi-colors'
2
2
 
3
- export function doHelp(
4
- command:string
5
- ) {
6
- switch (command) {
7
- case 'help':
8
- return helpHelp()
9
- case 'init':
10
- return helpInit()
11
- case 'create':
12
- return helpCreate()
13
- case 'build':
14
- return helpBuild()
15
- case 'test':
16
- return helpTest()
17
- case 'start':
18
- return helpStart()
19
- // case 'stop':
20
- // return helpStop()
21
- case 'package':
22
- return helpPackage()
23
- case 'deploy':
24
- return helpDeploy()
25
- case 'publish':
26
- return helpPublish()
27
- case 'settings':
28
- return helpSettings()
29
- case 'doctor':
30
- return helpDoctor()
31
- default:
32
- return helpDefault()
33
- }
3
+ export function doHelp (
4
+ command: string
5
+ ): void {
6
+ switch (command) {
7
+ case 'help':
8
+ return helpHelp()
9
+ case 'init':
10
+ return helpInit()
11
+ case 'create':
12
+ return helpCreate()
13
+ case 'build':
14
+ return helpBuild()
15
+ case 'test':
16
+ return helpTest()
17
+ case 'start':
18
+ return helpStart()
19
+ // case 'stop':
20
+ // return helpStop()
21
+ case 'package':
22
+ return helpPackage()
23
+ case 'deploy':
24
+ return helpDeploy()
25
+ case 'publish':
26
+ return helpPublish()
27
+ case 'settings':
28
+ return helpSettings()
29
+ case 'doctor':
30
+ return helpDoctor()
31
+ default:
32
+ return helpDefault()
33
+ }
34
34
  }
35
- function helpDefault() {
36
- console.log('lift is the command-line tool of the MistLift framework.');
37
- console.log("");
38
- console.log(ac.bold("Usage: " + ac.grey("lift " + ac.grey.dim("command [args]"))));
39
- console.log("where " + ac.grey.dim("command") + " is one of:");
40
- console.log(" " + ac.blue.bold("help " + ac.grey.dim("[command]")) + " -- this list, or help on a given command");
41
- console.log(" " + ac.blue.bold("init") + " -- create or prepare a directory as a MistLift project");
42
- console.log(" " + ac.blue.bold("create " + ac.grey.italic("functionName")) + " -- define and create a new API function");
43
- console.log(" " + ac.green("build") + " -- build the project");
44
- console.log(" " + ac.green("test") + " -- build, and run unit tests");
45
- console.log(" " + ac.cyan.bold("start") + " -- start the local express server");
46
- // console.log(" " + ac.cyan.bold("stop") + " -- stop the local express server");
47
- console.log(" " + ac.green("package "+ ac.grey.italic("[functionName]")) + " -- builds and packages functions into lambda-ready zips");
48
- console.log(" " + ac.green("deploy " + ac.grey.italic("[functionName]")) + " -- builds, packages, and deploys function packages to AWS lambda");
49
- console.log(" " + ac.blue.bold("publish") + " -- publishes the API and binds to the deployed functions");
50
- console.log(" " + ac.blue.bold("settings") + " -- sets up cloud settings");
51
- console.log(" " + ac.blue.bold("doctor") + " -- checks MistLift installation and status");
52
- console.log('');
53
- console.log("use " + ac.bold("lift help " + ac.grey.dim('[command]')) + " for command arguments and detals.");
54
- console.log(ac.italic("use " + ac.bold("lift version " +ac.grey.dim("or lift -v or lift --version") + ac.grey(" to see current running version of MistLift"))))
35
+ function helpDefault (): void {
36
+ console.log('lift is the command-line tool of the MistLift framework.')
37
+ console.log('')
38
+ console.log(ac.bold('Usage: ' + ac.grey('lift ' + ac.grey.dim('command [args]'))))
39
+ console.log('where ' + ac.grey.dim('command') + ' is one of:')
40
+ console.log(' ' + ac.blue.bold('help ' + ac.grey.dim('[command]')) + ' -- this list, or help on a given command')
41
+ console.log(' ' + ac.blue.bold('init') + ' -- create or prepare a directory as a MistLift project')
42
+ console.log(' ' + ac.blue.bold('create ' + ac.grey.italic('functionName')) + ' -- define and create a new API function')
43
+ console.log(' ' + ac.green('build') + ' -- build the project')
44
+ console.log(' ' + ac.green('test') + ' -- build, and run unit tests')
45
+ console.log(' ' + ac.cyan.bold('start') + ' -- start the local express server')
46
+ // console.log(" " + ac.cyan.bold("stop") + " -- stop the local express server");
47
+ console.log(' ' + ac.green('package ' + ac.grey.italic('[functionName]')) + ' -- builds and packages functions into lambda-ready zips')
48
+ console.log(' ' + ac.green('deploy ' + ac.grey.italic('[functionName]')) + ' -- builds, packages, and deploys function packages to AWS lambda')
49
+ console.log(' ' + ac.blue.bold('publish') + ' -- publishes the API and binds to the deployed functions')
50
+ console.log(' ' + ac.blue.bold('settings') + ' -- sets up cloud settings')
51
+ console.log(' ' + ac.blue.bold('doctor') + ' -- checks MistLift installation and status')
52
+ console.log('')
53
+ console.log('use ' + ac.bold('lift help ' + ac.grey.dim('[command]')) + ' for command arguments and detals.')
54
+ console.log(ac.italic('use ' + ac.bold('lift version ' + ac.grey.dim('or lift -v or lift --version') + ac.grey(' to see current running version of MistLift'))))
55
55
  }
56
- function printBanner(cmd:string) {
57
- let out = ' ' + ac.green('╭───────────────────────────────────────────────────────────────╮')+'\n'
58
- out += ' ' + ac.green('| |')+'\n'
59
- out += ' ' + ac.green('| Lift |')+'\n'
60
- out += ' ' + ac.green('| |')+'\n'
61
- out += ' ' + ac.green('╰───────────────────────────────────────────────────────────────╯')+'\n'
62
- out += ' ' + ac.bold.green(cmd)
63
- out += '\n'
64
- console.log(out)
56
+ function printBanner (cmd: string): void {
57
+ let out = ' ' + ac.green('╭───────────────────────────────────────────────────────────────╮') + '\n'
58
+ out += ' ' + ac.green('| |') + '\n'
59
+ out += ' ' + ac.green('| Lift |') + '\n'
60
+ out += ' ' + ac.green('| |') + '\n'
61
+ out += ' ' + ac.green('╰───────────────────────────────────────────────────────────────╯') + '\n'
62
+ out += ' ' + ac.bold.green(cmd)
63
+ out += '\n'
64
+ console.log(out)
65
65
  }
66
- function helpHelp() {
67
- printBanner("help")
68
- console.log("use " + ac.bold('lift help') + " by itself to see a list of commands");
69
- console.log("use " + ac.bold("lift help " + ac.grey.dim('[command]')) + " for help on a given command");
70
- console.log('');
66
+ function helpHelp (): void {
67
+ printBanner('help')
68
+ console.log('use ' + ac.bold('lift help') + ' by itself to see a list of commands')
69
+ console.log('use ' + ac.bold('lift help ' + ac.grey.dim('[command]')) + ' for help on a given command')
70
+ console.log('')
71
71
  }
72
- export function helpInit() {
73
- printBanner("init")
74
- console.log("use " + ac.bold('lift init .') + " from within a directory to init the current directory as a MistLift project");
75
- console.log("use " + ac.bold("lift init " + ac.grey.dim('projectPath')) + " to create a new directory at "
76
- + ac.grey.dim("projectPath") + " if it does not exist and init a MistLift project in that directory, if not already initialized");
77
- console.log("")
78
- console.log("This will begin an interactive session where you will be asked questions about the project you are creating.")
79
- console.log("The project will be complete and ready to run right away.")
80
- console.log("You can then modify the application to your needs.")
72
+ export function helpInit (): void {
73
+ printBanner('init')
74
+ console.log('use ' + ac.bold('lift init .') + ' from within a directory to init the current directory as a MistLift project')
75
+ console.log('use ' + ac.bold('lift init ' + ac.grey.dim('projectPath')) + ' to create a new directory at ' +
76
+ ac.grey.dim('projectPath') + ' if it does not exist and init a MistLift project in that directory, if not already initialized')
77
+ console.log('')
78
+ console.log('This will begin an interactive session where you will be asked questions about the project you are creating.')
79
+ console.log('The project will be complete and ready to run right away.')
80
+ console.log('You can then modify the application to your needs.')
81
81
  }
82
82
 
83
- export function helpCreate() {
84
- printBanner("create")
85
- console.log("use " + ac.bold('lift create') + ac.grey.dim(' functionName') + " to create a new function for your API")
86
- console.log("")
87
- console.log("your project folder (set up with "+ac.green.bold("init")+") will have a new function template created as "
88
- + ac.grey.dim("functionName")
89
- + " in a folder named "
90
- + ac.green.dim("functions") + " within your project directory")
91
- console.log("")
92
- console.log(ac.grey("The default function will display a'Hello World!' message when built and run" ));
93
- console.log(ac.grey("Modify the code to suit the needs of your function application"));
83
+ export function helpCreate (): void {
84
+ printBanner('create')
85
+ console.log('use ' + ac.bold('lift create') + ac.grey.dim(' functionName') + ' to create a new function for your API')
86
+ console.log('')
87
+ console.log('your project folder (set up with ' + ac.green.bold('init') + ') will have a new function template created as ' +
88
+ ac.grey.dim('functionName') +
89
+ ' in a folder named ' +
90
+ ac.green.dim('functions') + ' within your project directory')
91
+ console.log('')
92
+ console.log(ac.grey("The default function will display a'Hello World!' message when built and run"))
93
+ console.log(ac.grey('Modify the code to suit the needs of your function application'))
94
94
  }
95
- export function helpBuild() {
96
- printBanner("build")
97
- console.log("use "+ ac.bold('lift build') + " to build all your functions of the project")
98
- console.log("use "+ ac.bold('lift build') + " one or more function names to build these individually")
99
- console.log("")
100
- console.log("include "+ ac.bold('--clean') + " to force a rebuild, bypassing file date compare")
101
- console.log("include "+ ac.bold('--failfast') + " to stop after encountering an error")
102
- console.log("include "+ ac.bold('--deferfail') + " to build all, then report any errors (the default)")
103
- console.log("")
104
- console.log("The build step compiles your typescript (.ts) files into executable javascript (.js) files within a folder named 'build' in your project directory.")
105
- console.log("Files that are not updated are not rebuilt.")
106
- console.log("The build step is automatically invoked by other actions that depend upon it as a prerequisite, so it does not need to be explicitly run in normal operation.");
107
- console.log("");
95
+ export function helpBuild (): void {
96
+ printBanner('build')
97
+ console.log('use ' + ac.bold('lift build') + ' to build all your functions of the project')
98
+ console.log('use ' + ac.bold('lift build') + ' one or more function names to build these individually')
99
+ console.log('')
100
+ console.log('include ' + ac.bold('--clean') + ' to force a rebuild, bypassing file date compare')
101
+ console.log('include ' + ac.bold('--failfast') + ' to stop after encountering an error')
102
+ console.log('include ' + ac.bold('--deferfail') + ' to build all, then report any errors (the default)')
103
+ console.log('')
104
+ console.log("The build step compiles your typescript (.ts) files into executable javascript (.js) files within a folder named 'build' in your project directory.")
105
+ console.log('Files that are not updated are not rebuilt.')
106
+ console.log('The build step is automatically invoked by other actions that depend upon it as a prerequisite, so it does not need to be explicitly run in normal operation.')
107
+ console.log('')
108
108
  }
109
- export function helpTest() {
110
- printBanner("test")
111
- console.log("use "+ ac.bold( 'lift test') + " to invoke the testing framework and run unit tests for all functions")
112
- console.log("")
113
- console.log("Tests should be written in files within the named test folder for each created function. test files are given the suffix .test.ts")
114
- console.log("The test framework used is 'Tap' (https://node-tap.org)")
115
- console.log("");
109
+ export function helpTest (): void {
110
+ printBanner('test')
111
+ console.log('use ' + ac.bold('lift test') + ' to invoke the testing framework and run unit tests for all functions')
112
+ console.log('')
113
+ console.log('Tests should be written in files within the named test folder for each created function. test files are given the suffix .test.ts')
114
+ console.log("The test framework used is 'Tap' (https://node-tap.org)")
115
+ console.log('')
116
116
  }
117
- export function helpStart() {
118
- printBanner("start")
119
- console.log("use "+ ac.bold( 'lift start') + " to start running the local 'Express' server for local execution")
120
- console.log("")
121
- console.log("Functions may be run and tested via a local http server powered by express.")
122
- console.log("By default, access is at "+ac.blue("http://localhost:8081"));
123
- console.log("");
117
+ export function helpStart (): void {
118
+ printBanner('start')
119
+ console.log('use ' + ac.bold('lift start') + " to start running the local 'Express' server for local execution")
120
+ console.log('')
121
+ console.log('Functions may be run and tested via a local http server powered by express.')
122
+ console.log('By default, access is at ' + ac.blue('http://localhost:8081'))
123
+ console.log('')
124
124
  }
125
- export function helpStop() {
126
- printBanner("stop")
127
- console.log("use "+ ac.bold('lift stop') + " to stop the running local 'Express' server")
128
- console.log("")
129
- console.log("This will shut down the local server")
130
- console.log("")
125
+ export function helpStop (): void {
126
+ printBanner('stop')
127
+ console.log('use ' + ac.bold('lift stop') + " to stop the running local 'Express' server")
128
+ console.log('')
129
+ console.log('This will shut down the local server')
130
+ console.log('')
131
131
  }
132
- export function helpPackage() {
133
- printBanner("package")
134
- console.log("use "+ ac.bold('lift package') + " to build and package functions for cloud deployment")
135
- console.log("")
136
- console.log("options such as "+ac.bold('--clean')+ " may be specified to force a build prior to packaging")
137
- console.log("")
138
- console.log("Functions must be packaged into zip files before delivery to the cloud")
139
- console.log("The package command handles this by first insuring a fresh build and then packaging the function and its module dependencies")
140
- console.log(ac.grey("This action is invoked as part of deployment, and need not be invoked separately with this command"))
141
- console.log("");
132
+ export function helpPackage (): void {
133
+ printBanner('package')
134
+ console.log('use ' + ac.bold('lift package') + ' to build and package functions for cloud deployment')
135
+ console.log('')
136
+ console.log('options such as ' + ac.bold('--clean') + ' may be specified to force a build prior to packaging')
137
+ console.log('')
138
+ console.log('Functions must be packaged into zip files before delivery to the cloud')
139
+ console.log('The package command handles this by first insuring a fresh build and then packaging the function and its module dependencies')
140
+ console.log(ac.grey('This action is invoked as part of deployment, and need not be invoked separately with this command'))
141
+ console.log('')
142
142
  }
143
- export function helpDeploy() {
144
- printBanner("deploy")
145
- console.log("use " + ac.bold('lift deploy') + ac.grey.dim(' functionName') + " to package and deploy a function to the cloud")
146
- console.log("use " + ac.bold('lift deploy') + " with no argument to deploy all functions to the cloud")
147
- console.log("")
148
- console.log("options such as "+ac.bold('--clean')+ " may be specified to force a build prior to packaging")
149
- console.log("the option "+ac.bold('--no-package')+ " may be specified to deploy without repackaging")
150
- console.log("");
151
- console.log("functions will be built and packaged if necessary before deployment");
152
-
143
+ export function helpDeploy (): void {
144
+ printBanner('deploy')
145
+ console.log('use ' + ac.bold('lift deploy') + ac.grey.dim(' functionName') + ' to package and deploy a function to the cloud')
146
+ console.log('use ' + ac.bold('lift deploy') + ' with no argument to deploy all functions to the cloud')
147
+ console.log('')
148
+ console.log('options such as ' + ac.bold('--clean') + ' may be specified to force a build prior to packaging')
149
+ console.log('the option ' + ac.bold('--no-package') + ' may be specified to deploy without repackaging')
150
+ console.log('')
151
+ console.log('functions will be built and packaged if necessary before deployment')
153
152
  }
154
- export function helpPublish() {
155
- printBanner("publish")
156
- console.log("use " + ac.bold('lift publish') + " to publish the API to an accessible cloud endpoint")
157
- console.log("");
158
- console.log("The base url for the cloud API will be returned by this operation.")
159
- console.log("");
160
- console.log("Once published, updates to functions may be made with "+ac.bold('deploy')+ " without needing to republish.")
161
- console.log("Changes to webroot content or api definitions will require a new publish")
162
- console.log("Each publish operation returns a new URL. The previous URL is invalid.")
153
+ export function helpPublish (): void {
154
+ printBanner('publish')
155
+ console.log('use ' + ac.bold('lift publish') + ' to publish the API to an accessible cloud endpoint')
156
+ console.log('')
157
+ console.log('The base url for the cloud API will be returned by this operation.')
158
+ console.log('')
159
+ console.log('Once published, updates to functions may be made with ' + ac.bold('deploy') + ' without needing to republish.')
160
+ console.log('Changes to webroot content or api definitions will require a new publish')
161
+ console.log('Each publish operation returns a new URL. The previous URL is invalid.')
163
162
  }
164
- export function helpSettings() {
165
- printBanner("settings")
166
- console.log("use " + ac.bold('lift settings') + " to set or review the Cloud settings and configured options")
163
+ export function helpSettings (): void {
164
+ printBanner('settings')
165
+ console.log('use ' + ac.bold('lift settings') + ' to set or review the Cloud settings and configured options')
167
166
  }
168
- export function helpDoctor() {
169
- printBanner("doctor")
170
- console.log("use " + ac.bold('lift doctor') + " to report the status of your MistLift installation and dependencies")
167
+ export function helpDoctor (): void {
168
+ printBanner('doctor')
169
+ console.log('use ' + ac.bold('lift doctor') + ' to report the status of your MistLift installation and dependencies')
171
170
  }
@@ -16,47 +16,45 @@
16
16
 
17
17
  import * as path from 'path'
18
18
  import * as fs from 'fs'
19
- import {helpInit} from "./help";
20
- import {doDoctor} from "./doctor";
21
- import {interrogateUserForPackageJsonSettings} from "./actions/initQuestions";
22
- import {addPackageScripts, installPackage, installDevPackage} from "./actions/setupPackageJson";
19
+ import { helpInit } from './help'
20
+ import { interrogateUserForPackageJsonSettings } from './actions/initQuestions'
21
+ import { addPackageScripts, installPackage, installDevPackage } from './actions/setupPackageJson'
23
22
 
24
- export async function doInit(
25
- folder:string
26
- )
27
- {
28
- if(!folder) {
29
- helpInit();
30
- return;
31
- }
32
- const cwd = process.cwd()
33
- const refPath = path.isAbsolute(folder) ? path.normalize(folder) : path.normalize(path.join(cwd, folder))
34
- console.log(refPath)
35
- if(!fs.existsSync(refPath)) {
36
- fs.mkdirSync(refPath, {recursive: true})
37
- }
23
+ export async function doInit (
24
+ folder?: string
25
+ ): Promise<void> {
26
+ if (folder === undefined || folder === '') {
27
+ helpInit()
28
+ return
29
+ }
30
+ const cwd = process.cwd()
31
+ const refPath = path.isAbsolute(folder) ? path.normalize(folder) : path.normalize(path.join(cwd, folder))
32
+ console.log(refPath)
33
+ if (!fs.existsSync(refPath)) {
34
+ fs.mkdirSync(refPath, { recursive: true })
35
+ }
38
36
 
39
- const funcDir = path.join(refPath, "functions")
40
- if(!fs.existsSync(funcDir)) {
41
- fs.mkdirSync(funcDir)
42
- }
37
+ const funcDir = path.join(refPath, 'functions')
38
+ if (!fs.existsSync(funcDir)) {
39
+ fs.mkdirSync(funcDir)
40
+ }
43
41
 
44
- // make webroot with docs folder and placeholder yaml
45
- const webrootDocs = path.join(refPath, "webroot", "docs")
46
- if(!fs.existsSync(webrootDocs)) {
47
- fs.mkdirSync(webrootDocs, {recursive: true})
48
- const yaml = path.join(webrootDocs, 'apidoc.yaml');
49
- fs.writeFileSync(yaml, '');
50
- const swaggerSrcDir = path.join(__dirname, '..', '..', 'templateData')
51
- fs.copyFileSync(path.join(swaggerSrcDir, 'swagger-ui.css'), path.join(webrootDocs, 'swagger-ui.css'));
52
- fs.copyFileSync(path.join(swaggerSrcDir, 'swagger-ui-bundle.js'), path.join(webrootDocs, 'swagger-ui-bundle.js'));
53
- fs.copyFileSync(path.join(swaggerSrcDir, 'swagger-ui-standalone-preset.js'), path.join(webrootDocs, 'swagger-ui-standalone-preset.js'));
54
- }
42
+ // make webroot with docs folder and placeholder yaml
43
+ const webrootDocs = path.join(refPath, 'webroot', 'docs')
44
+ if (!fs.existsSync(webrootDocs)) {
45
+ fs.mkdirSync(webrootDocs, { recursive: true })
46
+ const yaml = path.join(webrootDocs, 'apidoc.yaml')
47
+ fs.writeFileSync(yaml, '')
48
+ const swaggerSrcDir = path.join(__dirname, '..', '..', 'templateData')
49
+ fs.copyFileSync(path.join(swaggerSrcDir, 'swagger-ui.css'), path.join(webrootDocs, 'swagger-ui.css'))
50
+ fs.copyFileSync(path.join(swaggerSrcDir, 'swagger-ui-bundle.js'), path.join(webrootDocs, 'swagger-ui-bundle.js'))
51
+ fs.copyFileSync(path.join(swaggerSrcDir, 'swagger-ui-standalone-preset.js'), path.join(webrootDocs, 'swagger-ui-standalone-preset.js'))
52
+ }
55
53
 
56
- await interrogateUserForPackageJsonSettings(refPath)
57
- await addPackageScripts(refPath)
58
- await installDevPackage(refPath,"@types/node")
59
- await installDevPackage(refPath,"typescript")
60
- await installDevPackage(refPath,"tap")
61
- await installPackage(refPath,"@tremho/inverse-y")
54
+ await interrogateUserForPackageJsonSettings(refPath)
55
+ await addPackageScripts(refPath)
56
+ await installDevPackage(refPath, '@types/node')
57
+ await installDevPackage(refPath, 'typescript')
58
+ await installDevPackage(refPath, 'tap')
59
+ await installPackage(refPath, '@tremho/inverse-y')
62
60
  }