@symbo.ls/cli 0.6.18 → 0.6.22

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/bin/fetch.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import 'v8-compile-cache'
4
3
  import fs from 'fs'
5
4
  import fetch from 'node-fetch'
6
5
  import chalk from 'chalk'
7
6
  import { loadModule } from './require.js'
8
7
  import { Command } from 'commander'
8
+ import { exec } from 'child_process'
9
9
 
10
10
  const pkg = loadModule('../package.json')
11
11
  const program = new Command()
@@ -17,6 +17,31 @@ const LOG_DEST = 'https://raw.githubusercontent.com/symbo-ls/uikit/packages/conf
17
17
  program
18
18
  .version(pkg.version)
19
19
 
20
+ program
21
+ .command('init [destination]')
22
+ .description('Initialize a repository')
23
+ .option('-m, --mode', 'Which Symbols to install (domql, react)')
24
+ .action(async (mode) => {
25
+ const packageName = `@symbo.ls/${mode || 'uikit'}`
26
+ console.log('Adding', chalk.green.bold(packageName))
27
+
28
+ exec(`yarn add ${packageName} --force`, (error, stdout, stderr) => {
29
+ if (error) {
30
+ console.log(`error: ${error.message}`)
31
+ return
32
+ }
33
+ if (stderr) {
34
+ console.log(`stderr: ${stderr}`)
35
+ // return;
36
+ }
37
+ console.log('')
38
+ console.log(`stdout: ${stdout}`)
39
+ console.log('\n')
40
+ console.log(chalk.green.bold(packageName), 'successfuly added!')
41
+ console.log('')
42
+ console.log(chalk.dim('Now you can import components like:'), `import { Button } from "${chalk.green.bold(packageName)}"`)
43
+ })
44
+ })
20
45
  program
21
46
  .command('fetch [destination]')
22
47
  .description('Fetch symbols')
@@ -25,6 +50,8 @@ program
25
50
  const body = await response.json()
26
51
  const { version, ...config } = body
27
52
 
53
+ console.log(source, destination)
54
+
28
55
  console.log('')
29
56
  console.log(chalk.bold('Symbols'), 'config fetched:', chalk.green(version))
30
57
  console.log(chalk.dim('- Default config from:'), chalk.dim.underline(LOG_DEST))
@@ -33,10 +60,13 @@ program
33
60
  console.log(chalk.dim('- .symbolsrc.json created:'), chalk.dim.underline(path))
34
61
  console.log('')
35
62
 
36
- fs.writeFile(path, JSON.stringify(body), err => {
63
+ const bodyString = JSON.stringify(body)
64
+ fs.writeFile(path, bodyString, err => {
37
65
  if (err) {
38
66
  console.log('Error writing file', err)
39
67
  } else {
68
+ const initPath = process.cwd() + 'node_modules/@symbo.ls/scratch-init/.symbolsrc.json'
69
+ fs.writeFile(initPath, bodyString, err => { if (err) throw err })
40
70
  console.log('Successfully wrote file')
41
71
  }
42
72
  })
@@ -49,5 +79,5 @@ program
49
79
  }
50
80
  })
51
81
 
52
- var args = process.argv
82
+ const args = process.argv
53
83
  program.parse(args)
package/bin/index.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import 'v8-compile-cache'
4
+ import './init.js'
5
+ import './fetch.js'
package/bin/init.js ADDED
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ import { exec } from 'child_process'
4
+ import chalk from 'chalk'
5
+
6
+ import { Command } from 'commander'
7
+ const program = new Command()
8
+
9
+ program
10
+ .command('init [destination]')
11
+ .description('Initialize a repository')
12
+ .option('-m, --mode', 'Which Symbols to install (domql, react)')
13
+ .action(async (mode) => {
14
+ const packageName = `@symbo.ls/${mode || 'uikit'}`
15
+ console.log('Adding', chalk.green.bold(packageName))
16
+
17
+ exec(`yarn add ${packageName} --force`, (error, stdout, stderr) => {
18
+ if (error) {
19
+ console.log(`error: ${error.message}`)
20
+ return
21
+ }
22
+ if (stderr) {
23
+ console.warn(`stderr: ${stderr}`)
24
+ return
25
+ }
26
+ console.log(`stdout: ${stdout}`)
27
+ console.log(chalk.green.bold(packageName), 'successfuly added!')
28
+ console.log('')
29
+ console.log(chalk.dim.underline('Now you can import components like:'), `import { Button } from "${chalk.green.bold(packageName)}""`)
30
+ })
31
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "0.6.18",
3
+ "version": "0.6.22",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "bin/fetch.js",
6
6
  "author": "Symbols",
@@ -8,10 +8,10 @@
8
8
  "private": false,
9
9
  "type": "module",
10
10
  "bin": {
11
- "symbo-ls": "bin/fetch.js"
11
+ "symbo-ls": "bin/index.js"
12
12
  },
13
13
  "scripts": {
14
- "start": "node bin/fetch.js",
14
+ "start": "node bin/index.js",
15
15
  "vpush": "git add . && git commit -am 'version update' && git push",
16
16
  "vpatch": "npm version patch && npm publish"
17
17
  },
@@ -22,6 +22,14 @@
22
22
  "v8-compile-cache": "^2.3.0"
23
23
  },
24
24
  "devDependencies": {
25
- "np": "^7.6.0"
25
+ "np": "^7.6.0",
26
+ "@babel/core": "^7.10.4",
27
+ "@babel/preset-env": "^7.10.4",
28
+ "eslint": "^7.12.1",
29
+ "babel-eslint": "^10.0.3",
30
+ "standard": "^16.0.1"
31
+ },
32
+ "standard": {
33
+ "parser": "babel-eslint"
26
34
  }
27
35
  }