@newlogic-digital/cli 1.2.0 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newlogic-digital/cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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) {
@@ -38,7 +58,7 @@ async function install(name, branch) {
38
58
  if (install === 'yes') {
39
59
  execSync(`cd ${name || '.'} && composer install`)
40
60
 
41
- if (fs.existsSync(resolve(process.cwd(), 'Makefile'))) {
61
+ if (fs.existsSync(resolve(join(process.cwd(), name || ''), 'Makefile'))) {
42
62
  execSync(`cd ${name || '.'} && make install ${branch || ''}`)
43
63
  } else {
44
64
  execSync(`cd ${name || '.'} && composer install-${branch || ''}`)
@@ -73,7 +93,7 @@ async function migrations(name) {
73
93
  {
74
94
  type: 'select',
75
95
  name: 'install',
76
- message: 'Init phinx migrations?',
96
+ message: 'Init phinx migrations and seed?',
77
97
  choices: [
78
98
  { title: 'yes', value: 'yes' },
79
99
  { title: 'no', value: 'no' }
@@ -106,7 +126,7 @@ async function prepare() {
106
126
 
107
127
  export default async function cms(name, { variant, branch }) {
108
128
  if (name) {
109
- clone(name, { variant, branch })
129
+ await clone(name, { variant, branch })
110
130
  await install(name, branch)
111
131
  await prepare()
112
132
  await dev()
@@ -114,36 +134,42 @@ export default async function cms(name, { variant, branch }) {
114
134
  return
115
135
  }
116
136
 
117
- if (fs.existsSync(tempDir)) {
137
+ if (!fs.existsSync(resolve(process.cwd(), 'composer.json'))) {
138
+ if (fs.existsSync(tempDir)) {
139
+ fse.removeSync(tempDir)
140
+ }
141
+
142
+ await clone(tempDir, { variant, branch })
143
+
144
+ await move('.docker')
145
+ await move('app')
146
+ await move('bin')
147
+ await move('config')
148
+ await move('log')
149
+ await move('public/index.php')
150
+ await move('src/views')
151
+ await move('storage')
152
+ await move('temp')
153
+ await move('tests')
154
+ await move('.gitignore', { overwrite: true })
155
+ await move('README.md', { overwrite: true })
156
+ await move('composer.json')
157
+ await move('composer.lock')
158
+ await move('docker-compose.yml')
159
+ await move('Makefile') // deprecated
160
+ await move('phpstan.neon')
161
+ await move('phpunit.xml')
162
+ await move('pint.json')
163
+ await move('rector.php')
164
+ await fse.move(join(tempDir, '.gitlab-ci.prod.yml'), resolve(process.cwd(), '.gitlab-ci.yml'), { overwrite: true }).catch(err => console.log(`${pc.red(err)} - .gitlab-ci.yml`))
165
+
118
166
  fse.removeSync(tempDir)
167
+ } else {
168
+ console.log(pc.yellow('Project files already exist in the directory, skipping copy step (delete composer.json to force)'))
119
169
  }
120
170
 
121
- clone(tempDir, { variant, branch })
122
-
123
- await move('.docker')
124
- await move('app')
125
- await move('bin')
126
- await move('config')
127
- await move('log')
128
- await move('public/index.php')
129
- await move('src/views')
130
- await move('storage')
131
- await move('temp')
132
- await move('tests')
133
- await move('.gitignore', { overwrite: true })
134
- await move('README.md', { overwrite: true })
135
- await move('composer.json')
136
- await move('composer.lock')
137
- await move('docker-compose.yml')
138
- await move('Makefile') // deprecated
139
- await move('phpstan.neon')
140
- await move('phpunit.xml')
141
- await move('pint.json')
142
- await move('rector.php')
143
- await fse.move(join(tempDir, '.gitlab-ci.prod.yml'), resolve(process.cwd(), '.gitlab-ci.yml'), { overwrite: true }).catch(err => console.log(`${pc.red(err)} - .gitlab-ci.yml`))
144
-
145
- fse.removeSync(tempDir)
146
-
147
171
  await install(name, branch)
148
172
  await prepare()
173
+ await dev()
174
+ await migrations()
149
175
  }
@@ -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