@newlogic-digital/cli 0.0.8 → 0.0.11

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,11 +1,10 @@
1
1
  {
2
2
  "name": "@newlogic-digital/cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.11",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "newlogic-cli": "index.mjs",
7
- "newlogic": "index.mjs",
8
- "nl": "index.mjs"
7
+ "newlogic": "index.mjs"
9
8
  },
10
9
  "scripts": {
11
10
  "eslint": "eslint '**/*.mjs' --fix"
@@ -4,11 +4,12 @@ import fs from 'fs'
4
4
  import os from 'os'
5
5
  import pc from 'picocolors'
6
6
  import fse from 'fs-extra'
7
+ import prompts from 'prompts'
7
8
 
8
9
  const tempDir = join(os.tmpdir(), 'newlogic-cms-web')
9
10
 
10
11
  async function move(path) {
11
- await fse.move(join(tempDir, path), resolve(process.cwd(), path)).catch(err => console.log(pc.red(err)))
12
+ await fse.move(join(tempDir, path), resolve(process.cwd(), path)).catch(err => console.log(`${pc.red(err)} - ${path}` ))
12
13
  }
13
14
 
14
15
  function clone(path, { variant, branch }) {
@@ -21,9 +22,47 @@ function clone(path, { variant, branch }) {
21
22
  execSync(`git clone -b ${branch} --single-branch --depth 1 git@git.newlogic.cz:newlogic-dev/${variant}.git ${path}`)
22
23
  }
23
24
 
25
+ async function install(name) {
26
+ const { install } = await prompts([
27
+ {
28
+ type: 'select',
29
+ name: 'install',
30
+ message: 'Install project?',
31
+ choices: [
32
+ { title: 'yes', value: 'yes' },
33
+ { title: 'no', value: 'no' }
34
+ ]
35
+ }
36
+ ])
37
+
38
+ if (install === 'yes') {
39
+ execSync(`cd ${name || '.'} && make install`)
40
+ }
41
+ }
42
+
43
+ async function prepare() {
44
+ const { install } = await prompts([
45
+ {
46
+ type: 'select',
47
+ name: 'install',
48
+ message: 'Prepare project with templates from frontend?',
49
+ choices: [
50
+ { title: 'yes', value: 'yes' },
51
+ { title: 'no', value: 'no' }
52
+ ]
53
+ }
54
+ ])
55
+
56
+ if (install === 'yes') {
57
+ execSync(`newlogic cms prepare`)
58
+ }
59
+ }
60
+
24
61
  export default async function cms(name, { variant, branch }) {
25
62
  if (name) {
26
63
  clone(name, { variant, branch })
64
+ await install(name)
65
+ await prepare()
27
66
  return
28
67
  }
29
68
 
@@ -50,4 +89,7 @@ export default async function cms(name, { variant, branch }) {
50
89
  await move('pint.json')
51
90
 
52
91
  fse.removeSync(tempDir)
92
+
93
+ await install()
94
+ await prepare()
53
95
  }
@@ -35,7 +35,7 @@ async function init(project, name) {
35
35
  ])
36
36
 
37
37
  if (project === 'ui') {
38
- ui(name, { branch })
38
+ await ui(name, { branch })
39
39
  }
40
40
 
41
41
  if (project === 'cms') {
@@ -1,5 +1,22 @@
1
1
  import { execSync } from '../../utils.mjs'
2
+ import prompts from 'prompts'
2
3
 
3
- export default function ui(name, { branch }) {
4
+ export default async function ui(name, { branch }) {
4
5
  execSync(`git clone -b ${branch} --single-branch --depth 1 git@git.newlogic.cz:newlogic-dev/newlogic-ui.git ${name || '.'}`)
6
+
7
+ const { install } = await prompts([
8
+ {
9
+ type: 'select',
10
+ name: 'install',
11
+ message: 'Install project?',
12
+ choices: [
13
+ { title: 'yes', value: 'yes' },
14
+ { title: 'no', value: 'no' }
15
+ ]
16
+ }
17
+ ])
18
+
19
+ if (install === 'yes') {
20
+ execSync(`cd ${name || '.'} && npm i`)
21
+ }
5
22
  }