@zeedhi/teknisa-cli 1.108.0 → 1.109.1

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 +21 -21
  2. package/README.md +5 -5
  3. package/bin/teknisa.js +117 -117
  4. package/package.json +2 -2
  5. package/src/create.js +118 -118
  6. package/src/generate.js +20 -20
  7. package/src/util/component/createEmptyComponent.js +145 -145
  8. package/src/util/component/createJest.js +19 -19
  9. package/src/util/component/createNpmignore.js +14 -14
  10. package/src/util/component/createPackage.js +52 -52
  11. package/src/util/component/createReadme.js +15 -15
  12. package/src/util/component/createRollup.js +15 -15
  13. package/src/util/component/createTsConfig.js +24 -24
  14. package/src/util/component/createTsLint.js +18 -18
  15. package/src/util/component/run.js +54 -54
  16. package/src/util/enhanceErrorMessages.js +13 -13
  17. package/src/util/project/editCliVersion.js +17 -17
  18. package/src/util/project/editPackageJson.js +19 -19
  19. package/src/util/project/module/.env.development +1 -1
  20. package/src/util/project/module/.env.production +1 -1
  21. package/src/util/project/module/.eslintrc.js +40 -40
  22. package/src/util/project/module/GruntFile.js +15 -15
  23. package/src/util/project/module/README.md +22 -22
  24. package/src/util/project/module/cliVersion.json +2 -2
  25. package/src/util/project/module/gitignore.template +21 -21
  26. package/src/util/project/module/package.json +68 -68
  27. package/src/util/project/module/postcss.config.js +5 -5
  28. package/src/util/project/module/public/index.html +17 -17
  29. package/src/util/project/module/public/metadata/notfound.json +14 -14
  30. package/src/util/project/module/public/metadata/unauthorized.json +14 -14
  31. package/src/util/project/module/public/robots.txt +2 -2
  32. package/src/util/project/module/src/App.vue +134 -134
  33. package/src/util/project/module/src/config/config.ts +17 -17
  34. package/src/util/project/module/src/config/devEnvironment.json +4 -4
  35. package/src/util/project/module/src/config/prodEnvironment.json +3 -3
  36. package/src/util/project/module/src/controllers/AppController.ts +5 -5
  37. package/src/util/project/module/src/controllers/index.ts +5 -5
  38. package/src/util/project/module/src/main.ts +17 -17
  39. package/src/util/project/module/src/plugins/index.ts +6 -6
  40. package/src/util/project/module/src/plugins/vuetify.ts +11 -11
  41. package/src/util/project/module/src/plugins/zeedhi.ts +50 -50
  42. package/src/util/project/module/src/registerServiceWorker.ts +32 -32
  43. package/src/util/project/module/src/shims-tsx.d.ts +13 -13
  44. package/src/util/project/module/src/shims-vue.d.ts +5 -5
  45. package/src/util/project/module/src/theme/index.ts +12 -12
  46. package/src/util/project/module/tsconfig.json +45 -45
  47. package/src/util/project/module/vue.config.js +107 -107
  48. package/src/util/project/product/.env.development +3 -3
  49. package/src/util/project/product/.env.production +2 -2
  50. package/src/util/project/product/.eslintrc.js +41 -41
  51. package/src/util/project/product/GruntFile.js +15 -15
  52. package/src/util/project/product/README.md +22 -22
  53. package/src/util/project/product/cliVersion.json +2 -2
  54. package/src/util/project/product/gitignore.template +21 -21
  55. package/src/util/project/product/package.json +69 -69
  56. package/src/util/project/product/postcss.config.js +5 -5
  57. package/src/util/project/product/public/assets/img/icons/safari-pinned-tab.svg +33 -33
  58. package/src/util/project/product/public/assets/img/image-not-found.svg +3 -3
  59. package/src/util/project/product/public/index.html +19 -19
  60. package/src/util/project/product/public/metadata/home.json +63 -63
  61. package/src/util/project/product/public/metadata/login.json +6 -6
  62. package/src/util/project/product/public/metadata/menu.json +28 -28
  63. package/src/util/project/product/public/metadata/notfound.json +14 -14
  64. package/src/util/project/product/public/robots.txt +2 -2
  65. package/src/util/project/product/src/App.vue +192 -192
  66. package/src/util/project/product/src/components/img-link/ImgLink.ts +17 -17
  67. package/src/util/project/product/src/components/img-link/ImgLink.vue +7 -7
  68. package/src/util/project/product/src/components/img-link/common/ImgLink.ts +32 -32
  69. package/src/util/project/product/src/components/index.ts +4 -4
  70. package/src/util/project/product/src/config/config.ts +22 -22
  71. package/src/util/project/product/src/config/devEnvironment.json +22 -22
  72. package/src/util/project/product/src/config/prodEnvironment.json +22 -22
  73. package/src/util/project/product/src/controllers/AppController.ts +119 -119
  74. package/src/util/project/product/src/controllers/LoginController.ts +17 -17
  75. package/src/util/project/product/src/controllers/index.ts +7 -7
  76. package/src/util/project/product/src/main.ts +22 -22
  77. package/src/util/project/product/src/plugins/index.ts +11 -11
  78. package/src/util/project/product/src/plugins/vuetify.ts +11 -11
  79. package/src/util/project/product/src/plugins/zeedhi.ts +72 -72
  80. package/src/util/project/product/src/registerServiceWorker.ts +32 -32
  81. package/src/util/project/product/src/router/index.ts +76 -76
  82. package/src/util/project/product/src/router/routes.ts +37 -37
  83. package/src/util/project/product/src/shims-tsx.d.ts +13 -13
  84. package/src/util/project/product/src/shims-vue.d.ts +5 -5
  85. package/src/util/project/product/src/store.ts +26 -26
  86. package/src/util/project/product/src/theme/index.ts +10 -10
  87. package/src/util/project/product/src/views/Microservice.ts +57 -57
  88. package/src/util/project/product/src/views/Microservice.vue +13 -13
  89. package/src/util/project/product/tsconfig.json +46 -46
  90. package/src/util/project/product/vue.config.js +107 -107
  91. package/src/util/project/renameGitIgnore.js +14 -14
  92. package/src/util/project/run.js +15 -15
  93. package/src/util/validateName.js +21 -21
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Teknisa
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Teknisa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # Teknisa CLI
2
-
3
- ### Instalation ###
4
- To install, run:
5
- `npm install -g --save @zeedhi/teknisa-cli`
1
+ # Teknisa CLI
2
+
3
+ ### Instalation ###
4
+ To install, run:
5
+ `npm install -g --save @zeedhi/teknisa-cli`
package/bin/teknisa.js CHANGED
@@ -1,118 +1,118 @@
1
- #!/usr/bin/env node
2
- const chalk = require('chalk')
3
- const semver = require('semver')
4
- const requiredVersion = require('../package.json').engines.node
5
-
6
- function checkNodeVersion (wanted, id) {
7
- if (!semver.satisfies(process.version, wanted)) {
8
- console.log(chalk.red(
9
- 'You are using Node ' + process.version + ', but this version of ' + id +
10
- ' requires Node ' + wanted + '.\nPlease upgrade your Node version.'
11
- ))
12
- process.exit(1)
13
- }
14
- }
15
-
16
- checkNodeVersion(requiredVersion, 'teknisa-cli')
17
-
18
- const program = require('commander')
19
- const generateOptions = ['component']
20
-
21
- program
22
- .version(require('../package').version)
23
- .usage('<command> [options]')
24
-
25
- program
26
- .command('create <app-name>')
27
- .description('create a new Teknisa project using Zeedhi')
28
- .option('-f, --force', 'Overwrite target directory if it exists')
29
- .action(function(name, cmd) {
30
- require('../src/create')(name, cleanArgs(cmd))
31
- })
32
-
33
- program.on('--help', () => {
34
- console.log()
35
- console.log(` Run ${chalk.cyan(`teknisa <command> --help`)} for detailed usage of given command.`)
36
- console.log()
37
- })
38
-
39
- program
40
- .arguments('<command>')
41
- .action((cmd) => {
42
- program.outputHelp()
43
- console.log(` ` + chalk.red(`Unknown command ${chalk.yellow(cmd)}.`))
44
- console.log()
45
- })
46
-
47
- program.commands.forEach(c => c.on('--help', () => console.log()))
48
-
49
- const enhanceErrorMessages = require('../src/util/enhanceErrorMessages')
50
-
51
- enhanceErrorMessages('missingArgument', argName => {
52
- return `Missing required argument ${chalk.yellow(`<${argName}>`)}.`
53
- })
54
-
55
- enhanceErrorMessages('unknownArgument', argumentName => {
56
- return `Unknown argument ${chalk.yellow(argumentName)}.`
57
- })
58
-
59
- enhanceErrorMessages('unknownOption', optionName => {
60
- return `Unknown option ${chalk.yellow(optionName)}.`
61
- })
62
-
63
- enhanceErrorMessages('optionMissingArgument', (option, flag) => {
64
- return `Missing required argument for option ${chalk.yellow(option.flags)}` + (
65
- flag ? `, got ${chalk.yellow(flag)}` : ``
66
- )
67
- })
68
-
69
- program.parse(process.argv)
70
-
71
- if (!process.argv.slice(2).length) {
72
- program.outputHelp()
73
- }
74
-
75
- function camelize(str) {
76
- return str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : '')
77
- }
78
-
79
- function cleanArgs(cmd) {
80
- const args = {}
81
- cmd.options.forEach(o => {
82
- const key = camelize(o.long.replace(/^--/, ''))
83
- // if an option is not present and Command has a method with the same name
84
- // it should not be copied
85
- if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
86
- args[key] = cmd[key]
87
- }
88
- })
89
- return args
90
- }
91
-
92
- function generateAction(type, name, cmd) {
93
- if (type && name) {
94
- if (generateOptions.find(option => option === type)) {
95
- require('../src/generate')(name, cleanArgs(cmd))
96
- } else {
97
- this.unknownArgument(type)
98
- }
99
- } else {
100
- this.outputHelp()
101
- }
102
- }
103
-
104
- function generateHelper() {
105
- console.log('')
106
- console.log(chalk.white.bold(' Usage:'))
107
- console.log('')
108
- console.log(` ${chalk.gray('$')} ${chalk.green('teknisa g <type> <name>')}`)
109
- console.log('')
110
- console.log(chalk.white.bold(' Inputs:'))
111
- console.log('')
112
- console.log(` ${chalk.green('type')} ${chalk.gray('..........')} The type of feature (e.g. ${chalk.green(generateOptions.join(','))})`)
113
- console.log(` ${chalk.green('name')} ${chalk.gray('..........')} The name of the feature being generated`)
114
- console.log('')
115
- console.log(chalk.white.bold(' Examples:'))
116
- console.log('')
117
- console.log(` ${chalk.gray('$')} ${chalk.green('teknisa g component zd-clock')}`)
1
+ #!/usr/bin/env node
2
+ const chalk = require('chalk')
3
+ const semver = require('semver')
4
+ const requiredVersion = require('../package.json').engines.node
5
+
6
+ function checkNodeVersion (wanted, id) {
7
+ if (!semver.satisfies(process.version, wanted)) {
8
+ console.log(chalk.red(
9
+ 'You are using Node ' + process.version + ', but this version of ' + id +
10
+ ' requires Node ' + wanted + '.\nPlease upgrade your Node version.'
11
+ ))
12
+ process.exit(1)
13
+ }
14
+ }
15
+
16
+ checkNodeVersion(requiredVersion, 'teknisa-cli')
17
+
18
+ const program = require('commander')
19
+ const generateOptions = ['component']
20
+
21
+ program
22
+ .version(require('../package').version)
23
+ .usage('<command> [options]')
24
+
25
+ program
26
+ .command('create <app-name>')
27
+ .description('create a new Teknisa project using Zeedhi')
28
+ .option('-f, --force', 'Overwrite target directory if it exists')
29
+ .action(function(name, cmd) {
30
+ require('../src/create')(name, cleanArgs(cmd))
31
+ })
32
+
33
+ program.on('--help', () => {
34
+ console.log()
35
+ console.log(` Run ${chalk.cyan(`teknisa <command> --help`)} for detailed usage of given command.`)
36
+ console.log()
37
+ })
38
+
39
+ program
40
+ .arguments('<command>')
41
+ .action((cmd) => {
42
+ program.outputHelp()
43
+ console.log(` ` + chalk.red(`Unknown command ${chalk.yellow(cmd)}.`))
44
+ console.log()
45
+ })
46
+
47
+ program.commands.forEach(c => c.on('--help', () => console.log()))
48
+
49
+ const enhanceErrorMessages = require('../src/util/enhanceErrorMessages')
50
+
51
+ enhanceErrorMessages('missingArgument', argName => {
52
+ return `Missing required argument ${chalk.yellow(`<${argName}>`)}.`
53
+ })
54
+
55
+ enhanceErrorMessages('unknownArgument', argumentName => {
56
+ return `Unknown argument ${chalk.yellow(argumentName)}.`
57
+ })
58
+
59
+ enhanceErrorMessages('unknownOption', optionName => {
60
+ return `Unknown option ${chalk.yellow(optionName)}.`
61
+ })
62
+
63
+ enhanceErrorMessages('optionMissingArgument', (option, flag) => {
64
+ return `Missing required argument for option ${chalk.yellow(option.flags)}` + (
65
+ flag ? `, got ${chalk.yellow(flag)}` : ``
66
+ )
67
+ })
68
+
69
+ program.parse(process.argv)
70
+
71
+ if (!process.argv.slice(2).length) {
72
+ program.outputHelp()
73
+ }
74
+
75
+ function camelize(str) {
76
+ return str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : '')
77
+ }
78
+
79
+ function cleanArgs(cmd) {
80
+ const args = {}
81
+ cmd.options.forEach(o => {
82
+ const key = camelize(o.long.replace(/^--/, ''))
83
+ // if an option is not present and Command has a method with the same name
84
+ // it should not be copied
85
+ if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
86
+ args[key] = cmd[key]
87
+ }
88
+ })
89
+ return args
90
+ }
91
+
92
+ function generateAction(type, name, cmd) {
93
+ if (type && name) {
94
+ if (generateOptions.find(option => option === type)) {
95
+ require('../src/generate')(name, cleanArgs(cmd))
96
+ } else {
97
+ this.unknownArgument(type)
98
+ }
99
+ } else {
100
+ this.outputHelp()
101
+ }
102
+ }
103
+
104
+ function generateHelper() {
105
+ console.log('')
106
+ console.log(chalk.white.bold(' Usage:'))
107
+ console.log('')
108
+ console.log(` ${chalk.gray('$')} ${chalk.green('teknisa g <type> <name>')}`)
109
+ console.log('')
110
+ console.log(chalk.white.bold(' Inputs:'))
111
+ console.log('')
112
+ console.log(` ${chalk.green('type')} ${chalk.gray('..........')} The type of feature (e.g. ${chalk.green(generateOptions.join(','))})`)
113
+ console.log(` ${chalk.green('name')} ${chalk.gray('..........')} The name of the feature being generated`)
114
+ console.log('')
115
+ console.log(chalk.white.bold(' Examples:'))
116
+ console.log('')
117
+ console.log(` ${chalk.gray('$')} ${chalk.green('teknisa g component zd-clock')}`)
118
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/teknisa-cli",
3
- "version": "1.108.0",
3
+ "version": "1.109.1",
4
4
  "description": "Teknisa CLI",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -34,5 +34,5 @@
34
34
  "/src",
35
35
  "/bin"
36
36
  ],
37
- "gitHead": "c23fc7d327e5cd145b75229b2dca54967ec803d3"
37
+ "gitHead": "d40cf324961b699346b610c975eaedc46f1a154a"
38
38
  }
package/src/create.js CHANGED
@@ -1,119 +1,119 @@
1
- const fs = require('fs-extra')
2
- const path = require('path')
3
- const chalk = require('chalk')
4
- const clear = require('clear')
5
- const execa = require('execa')
6
- const inquirer = require('inquirer')
7
- const validateName = require('./util/validateName')
8
-
9
- async function create(name, options) {
10
-
11
- const cwd = options.cwd || process.cwd()
12
- const targetDir = path.resolve(cwd, name || '.')
13
-
14
- validateName(name, targetDir, options)
15
-
16
- if (fs.existsSync(targetDir) && !options.force) {
17
- console.error(chalk.red(`Target directory "${name}" already exists`))
18
- process.exit(1)
19
- }
20
-
21
- const { action } = await selectProjectType()
22
- if (!action) return
23
-
24
- const config = await getConfig(name, targetDir, action)
25
- await startConfig(config, options)
26
-
27
- console.log(`\nSuccessfully created project ${chalk.yellow(name)}.`)
28
- console.log(
29
- `${chalk.red('To learn how to configure your project check')} ` +
30
- `${chalk.yellow('http://docs.zeedhi.com/teknisa/create-product')}\n\n` +
31
- `Get started with the following commands:\n` +
32
- chalk.cyan(` ${chalk.gray('$')} cd ${name}\n`) +
33
- chalk.cyan(` ${chalk.gray('$')} npm run serve\n`)
34
- )
35
- }
36
-
37
- async function startConfig(config, options) {
38
- if (options.force) {
39
- console.log(`Removing ${chalk.cyan(config.name)}...`)
40
- fs.removeSync(config.targetDir)
41
- }
42
- await copyFiles(config.targetDir, config.action)
43
- await createProject(config)
44
- await installDeps(config.targetDir)
45
- }
46
-
47
- async function copyFiles(targetDir, action) {
48
- console.log(`Copying files...`)
49
- if (action === 'product') {
50
- await fs.copy(__dirname + '/util/project/product', targetDir);
51
- } else {
52
- await fs.copy(__dirname + '/util/project/module', targetDir);
53
- }
54
- }
55
-
56
- async function installDeps(targetDir) {
57
- console.log(`Installing dependencies...`)
58
- fs.removeSync(`${targetDir}/package-lock.json`)
59
- return await execa('npm', ['install', '--loglevel', 'error'], {
60
- cwd: targetDir,
61
- stdio: ['inherit', 'inherit', 'inherit']
62
- })
63
- }
64
-
65
- async function selectProjectType() {
66
- return await inquirer.prompt([
67
- {
68
- name: 'action',
69
- type: 'list',
70
- message: 'Select a project type:',
71
- choices: [
72
- { name: 'Product', value: 'product' },
73
- { name: 'Module', value: 'module' },
74
- { name: 'Cancel', value: false }
75
- ]
76
- }
77
- ])
78
- }
79
-
80
- async function getConfig(name, targetDir, action) {
81
- return await {
82
- name,
83
- action,
84
- targetDir,
85
- version: (await getVersion()).version,
86
- description: (await getDescription()).description,
87
- staticAppMetadata: true,
88
- }
89
- }
90
-
91
- async function getDescription() {
92
- return await inquirer.prompt([
93
- {
94
- name: 'description',
95
- type: 'input',
96
- message: `Enter a project description:`,
97
- default: 'Powered by Zeedhi',
98
- }
99
- ])
100
- }
101
-
102
- async function getVersion() {
103
- return await inquirer.prompt([
104
- {
105
- name: 'version',
106
- type: 'input',
107
- message: `Enter a project version:`,
108
- default: '0.1.0',
109
- }
110
- ])
111
- }
112
-
113
- async function createProject(config) {
114
- return await require('./util/project/run')(config)
115
- }
116
-
117
- module.exports = (...args) => {
118
- return create(...args)
1
+ const fs = require('fs-extra')
2
+ const path = require('path')
3
+ const chalk = require('chalk')
4
+ const clear = require('clear')
5
+ const execa = require('execa')
6
+ const inquirer = require('inquirer')
7
+ const validateName = require('./util/validateName')
8
+
9
+ async function create(name, options) {
10
+
11
+ const cwd = options.cwd || process.cwd()
12
+ const targetDir = path.resolve(cwd, name || '.')
13
+
14
+ validateName(name, targetDir, options)
15
+
16
+ if (fs.existsSync(targetDir) && !options.force) {
17
+ console.error(chalk.red(`Target directory "${name}" already exists`))
18
+ process.exit(1)
19
+ }
20
+
21
+ const { action } = await selectProjectType()
22
+ if (!action) return
23
+
24
+ const config = await getConfig(name, targetDir, action)
25
+ await startConfig(config, options)
26
+
27
+ console.log(`\nSuccessfully created project ${chalk.yellow(name)}.`)
28
+ console.log(
29
+ `${chalk.red('To learn how to configure your project check')} ` +
30
+ `${chalk.yellow('http://docs.zeedhi.com/teknisa/create-product')}\n\n` +
31
+ `Get started with the following commands:\n` +
32
+ chalk.cyan(` ${chalk.gray('$')} cd ${name}\n`) +
33
+ chalk.cyan(` ${chalk.gray('$')} npm run serve\n`)
34
+ )
35
+ }
36
+
37
+ async function startConfig(config, options) {
38
+ if (options.force) {
39
+ console.log(`Removing ${chalk.cyan(config.name)}...`)
40
+ fs.removeSync(config.targetDir)
41
+ }
42
+ await copyFiles(config.targetDir, config.action)
43
+ await createProject(config)
44
+ await installDeps(config.targetDir)
45
+ }
46
+
47
+ async function copyFiles(targetDir, action) {
48
+ console.log(`Copying files...`)
49
+ if (action === 'product') {
50
+ await fs.copy(__dirname + '/util/project/product', targetDir);
51
+ } else {
52
+ await fs.copy(__dirname + '/util/project/module', targetDir);
53
+ }
54
+ }
55
+
56
+ async function installDeps(targetDir) {
57
+ console.log(`Installing dependencies...`)
58
+ fs.removeSync(`${targetDir}/package-lock.json`)
59
+ return await execa('npm', ['install', '--loglevel', 'error'], {
60
+ cwd: targetDir,
61
+ stdio: ['inherit', 'inherit', 'inherit']
62
+ })
63
+ }
64
+
65
+ async function selectProjectType() {
66
+ return await inquirer.prompt([
67
+ {
68
+ name: 'action',
69
+ type: 'list',
70
+ message: 'Select a project type:',
71
+ choices: [
72
+ { name: 'Product', value: 'product' },
73
+ { name: 'Module', value: 'module' },
74
+ { name: 'Cancel', value: false }
75
+ ]
76
+ }
77
+ ])
78
+ }
79
+
80
+ async function getConfig(name, targetDir, action) {
81
+ return await {
82
+ name,
83
+ action,
84
+ targetDir,
85
+ version: (await getVersion()).version,
86
+ description: (await getDescription()).description,
87
+ staticAppMetadata: true,
88
+ }
89
+ }
90
+
91
+ async function getDescription() {
92
+ return await inquirer.prompt([
93
+ {
94
+ name: 'description',
95
+ type: 'input',
96
+ message: `Enter a project description:`,
97
+ default: 'Powered by Zeedhi',
98
+ }
99
+ ])
100
+ }
101
+
102
+ async function getVersion() {
103
+ return await inquirer.prompt([
104
+ {
105
+ name: 'version',
106
+ type: 'input',
107
+ message: `Enter a project version:`,
108
+ default: '0.1.0',
109
+ }
110
+ ])
111
+ }
112
+
113
+ async function createProject(config) {
114
+ return await require('./util/project/run')(config)
115
+ }
116
+
117
+ module.exports = (...args) => {
118
+ return create(...args)
119
119
  }
package/src/generate.js CHANGED
@@ -1,21 +1,21 @@
1
- const path = require('path')
2
- const chalk = require('chalk')
3
- const validateName = require('./util/validateName')
4
-
5
- async function generate(name, options) {
6
- const cwd = options.cwd || process.cwd()
7
- let targetDir = path.resolve(cwd, '.')
8
-
9
- if (options.path) {
10
- targetDir = path.resolve(targetDir, options.path)
11
- }
12
-
13
- validateName(name, targetDir, options)
14
- require('./util/component/run')(name, targetDir, options)
15
- console.log(`\nSuccessfully created component ${chalk.yellow(name)} at path ${chalk.yellow(targetDir)}.`)
16
-
17
- }
18
-
19
- module.exports = (...args) => {
20
- return generate(...args)
1
+ const path = require('path')
2
+ const chalk = require('chalk')
3
+ const validateName = require('./util/validateName')
4
+
5
+ async function generate(name, options) {
6
+ const cwd = options.cwd || process.cwd()
7
+ let targetDir = path.resolve(cwd, '.')
8
+
9
+ if (options.path) {
10
+ targetDir = path.resolve(targetDir, options.path)
11
+ }
12
+
13
+ validateName(name, targetDir, options)
14
+ require('./util/component/run')(name, targetDir, options)
15
+ console.log(`\nSuccessfully created component ${chalk.yellow(name)} at path ${chalk.yellow(targetDir)}.`)
16
+
17
+ }
18
+
19
+ module.exports = (...args) => {
20
+ return generate(...args)
21
21
  }