@newlogic-digital/cli 1.1.0 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newlogic-digital/cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "newlogic-cli": "index.mjs",
@@ -12,14 +12,34 @@ async function move(path, options = {}) {
12
12
  await fse.move(join(tempDir, path), resolve(process.cwd(), path), options).catch(err => console.log(`${pc.red(err)} - ${path}`))
13
13
  }
14
14
 
15
- function clone(path, { variant, branch }) {
15
+ async function clone(path, { variant, branch }) {
16
16
  if (variant === 'cms-web') {
17
17
  variant = 'newlogic-cms-next-web'
18
18
  } else if (variant === 'cms-eshop') {
19
19
  variant = 'newlogic-cms-next-eshop'
20
20
  }
21
21
 
22
- execSync(`git clone -b ${branch} --single-branch --depth 1 git@git.newlogic.cz:newlogic-dev/${variant}.git ${path}`)
22
+ const { clone } = await prompts([
23
+ {
24
+ type: 'select',
25
+ name: 'clone',
26
+ message: 'Clone with SSH or HTTPS?',
27
+ choices: [
28
+ { title: 'SSH', value: 'ssh' },
29
+ { title: 'HTTPS', value: 'https' }
30
+ ]
31
+ }
32
+ ])
33
+
34
+ let url = ''
35
+
36
+ if (clone === 'ssh') {
37
+ url = 'git@git.newlogic.cz:newlogic-digital'
38
+ } else if (clone === 'https') {
39
+ url = 'https://git.newlogic.cz/newlogic-digital'
40
+ }
41
+
42
+ execSync(`git clone -b ${branch} --single-branch --depth 1 ${url}/${variant}.git ${path}`)
23
43
  }
24
44
 
25
45
  async function install(name, branch) {
@@ -36,7 +56,53 @@ async function install(name, branch) {
36
56
  ])
37
57
 
38
58
  if (install === 'yes') {
39
- execSync(`cd ${name || '.'} && make install ${branch || ''}`)
59
+ execSync(`cd ${name || '.'} && composer install`)
60
+
61
+ if (fs.existsSync(resolve(process.cwd(), 'Makefile'))) {
62
+ execSync(`cd ${name || '.'} && make install ${branch || ''}`)
63
+ } else {
64
+ execSync(`cd ${name || '.'} && composer install-${branch || ''}`)
65
+ }
66
+
67
+ if (fs.existsSync(resolve(process.cwd(), 'package.json'))) {
68
+ execSync(`cd ${name || '.'} && npm i && npx vite build`)
69
+ }
70
+ }
71
+ }
72
+
73
+ async function dev(name) {
74
+ const { install } = await prompts([
75
+ {
76
+ type: 'select',
77
+ name: 'install',
78
+ message: 'Start dev server?',
79
+ choices: [
80
+ { title: 'yes', value: 'yes' },
81
+ { title: 'no', value: 'no' }
82
+ ]
83
+ }
84
+ ])
85
+
86
+ if (install === 'yes') {
87
+ execSync(`cd ${name || '.'} && composer dev-headless`)
88
+ }
89
+ }
90
+
91
+ async function migrations(name) {
92
+ const { install } = await prompts([
93
+ {
94
+ type: 'select',
95
+ name: 'install',
96
+ message: 'Init phinx migrations?',
97
+ choices: [
98
+ { title: 'yes', value: 'yes' },
99
+ { title: 'no', value: 'no' }
100
+ ]
101
+ }
102
+ ])
103
+
104
+ if (install === 'yes') {
105
+ execSync(`cd ${name || '.'} && composer phinx-init`)
40
106
  }
41
107
  }
42
108
 
@@ -60,9 +126,11 @@ async function prepare() {
60
126
 
61
127
  export default async function cms(name, { variant, branch }) {
62
128
  if (name) {
63
- clone(name, { variant, branch })
129
+ await clone(name, { variant, branch })
64
130
  await install(name, branch)
65
131
  await prepare()
132
+ await dev()
133
+ await migrations()
66
134
  return
67
135
  }
68
136
 
@@ -70,7 +138,7 @@ export default async function cms(name, { variant, branch }) {
70
138
  fse.removeSync(tempDir)
71
139
  }
72
140
 
73
- clone(tempDir, { variant, branch })
141
+ await clone(tempDir, { variant, branch })
74
142
 
75
143
  await move('.docker')
76
144
  await move('app')
@@ -79,6 +147,7 @@ export default async function cms(name, { variant, branch }) {
79
147
  await move('log')
80
148
  await move('public/index.php')
81
149
  await move('src/views')
150
+ await move('storage')
82
151
  await move('temp')
83
152
  await move('tests')
84
153
  await move('.gitignore', { overwrite: true })
@@ -86,7 +155,7 @@ export default async function cms(name, { variant, branch }) {
86
155
  await move('composer.json')
87
156
  await move('composer.lock')
88
157
  await move('docker-compose.yml')
89
- await move('Makefile')
158
+ await move('Makefile') // deprecated
90
159
  await move('phpstan.neon')
91
160
  await move('phpunit.xml')
92
161
  await move('pint.json')
@@ -97,4 +166,6 @@ export default async function cms(name, { variant, branch }) {
97
166
 
98
167
  await install(name, branch)
99
168
  await prepare()
169
+ await dev()
170
+ await migrations()
100
171
  }
@@ -4,7 +4,27 @@ import prompts from 'prompts'
4
4
  import { join, resolve } from 'path'
5
5
 
6
6
  export default async function ui(name, { branch }) {
7
- execSync(`git clone -b ${branch} --single-branch --depth 1 git@git.newlogic.cz:newlogic-dev/newlogic-ui.git ${name || '.'}`)
7
+ const { clone } = await prompts([
8
+ {
9
+ type: 'select',
10
+ name: 'clone',
11
+ message: 'Clone with SSH or HTTPS?',
12
+ choices: [
13
+ { title: 'SSH', value: 'ssh' },
14
+ { title: 'HTTPS', value: 'https' }
15
+ ]
16
+ }
17
+ ])
18
+
19
+ let url = ''
20
+
21
+ if (clone === 'ssh') {
22
+ url = 'git@git.newlogic.cz:newlogic-digital'
23
+ } else if (clone === 'https') {
24
+ url = 'https://git.newlogic.cz/newlogic-digital'
25
+ }
26
+
27
+ execSync(`git clone -b ${branch} --single-branch --depth 1 ${url}/newlogic-ui.git ${name || '.'}`)
8
28
 
9
29
  const gitPath = name ? join(resolve(process.cwd(), name), '.git') : resolve(process.cwd(), '.git')
10
30