@symbo.ls/cli 0.6.12 → 0.6.20

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,20 +1,47 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import 'v8-compile-cache'
4
- import { loadModule } from './require.js'
5
- import { Command } from 'commander'
3
+ import fs from 'fs'
6
4
  import fetch from 'node-fetch'
7
5
  import chalk from 'chalk'
6
+ import { loadModule } from './require.js'
7
+ import { Command } from 'commander'
8
+ import { exec } from 'child_process'
8
9
 
9
10
  const pkg = loadModule('../package.json')
10
11
  const program = new Command()
11
12
 
12
13
  const API_URL = 'https://api.symbols.app/' // eslint-disable-line
13
- const DEFAULT_CONFIG = 'https://raw.githubusercontent.com/symbo-ls/uikit/8e7026a2216c68efad260961a77c9302d34c7aa4/packages/config-default/src/config.json'
14
+ const DEFAULT_CONFIG = 'https://raw.githubusercontent.com/symbo-ls/uikit/feature/monorepo/packages/config-default/src/config.json'
15
+ const LOG_DEST = 'https://raw.githubusercontent.com/symbo-ls/uikit/packages/config-default/src/config.json'
14
16
 
15
17
  program
16
18
  .version(pkg.version)
17
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
+ })
18
45
  program
19
46
  .command('fetch [destination]')
20
47
  .description('Fetch symbols')
@@ -23,11 +50,14 @@ program
23
50
  const body = await response.json()
24
51
  const { version, ...config } = body
25
52
 
53
+ console.log(source, destination)
54
+
26
55
  console.log('')
27
- console.log(chalk.bold('Symbols'), 'config received: ', chalk.green(version))
56
+ console.log(chalk.bold('Symbols'), 'config fetched:', chalk.green(version))
57
+ console.log(chalk.dim('- Default config from:'), chalk.dim.underline(LOG_DEST))
28
58
 
29
59
  const path = process.cwd() + '/.symbolsrc.json'
30
- console.log(chalk.dim('Default config fetched: '), chalk.dim.underline(path))
60
+ console.log(chalk.dim('- .symbolsrc.json created:'), chalk.dim.underline(path))
31
61
  console.log('')
32
62
 
33
63
  fs.writeFile(path, JSON.stringify(body), err => {
@@ -46,5 +76,5 @@ program
46
76
  }
47
77
  })
48
78
 
49
- var args = process.argv
79
+ const args = process.argv
50
80
  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/bin/require.js CHANGED
@@ -4,6 +4,7 @@ export const loadModule = async (modulePath) => {
4
4
  try {
5
5
  return await import(modulePath)
6
6
  } catch (e) {
7
- throw new ImportError(`Unable to import module ${modulePath}`)
7
+ console.warn('Cant found', modulePath)
8
+ // throw new ImportError(`Unable to import module ${modulePath}`)
8
9
  }
9
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "0.6.12",
3
+ "version": "0.6.20",
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
  }