@symbo.ls/cli 0.6.4 → 0.6.9

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.
Files changed (2) hide show
  1. package/bin/fetch.js +66 -0
  2. package/package.json +22 -2
package/bin/fetch.js ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+
3
+ import 'v8-compile-cache'
4
+ import { createRequire } from 'module'
5
+ import { Command } from 'commander'
6
+ import fetch from 'node-fetch'
7
+ import chalk from 'chalk'
8
+ import fs from 'fs'
9
+
10
+ const require = createRequire(import.meta.url)
11
+ const pkg = require('../package.json')
12
+ const program = new Command()
13
+
14
+ const API_URL = 'https://api.symbols.app/' // eslint-disable-line
15
+ const DEFAULT_CONFIG = 'https://raw.githubusercontent.com/symbo-ls/uikit/8e7026a2216c68efad260961a77c9302d34c7aa4/packages/config-default/src/config.json'
16
+
17
+ program
18
+ .version(pkg.version)
19
+
20
+ // program
21
+ // .command('login [destination]')
22
+ // .description('Sign in to Symbols')
23
+ // .argument('<username>', 'user to login')
24
+ // .argument('[password]', 'password for user, if required', 'no password given')
25
+ // .action(async (username, password) => {
26
+ // console.log('username:', username)
27
+ // console.log('password:', password)
28
+
29
+ // const response = await fetch(API_URL)
30
+ // const body = await response.json()
31
+ // console.log(body)
32
+ // })
33
+
34
+ program
35
+ .command('fetch [destination]')
36
+ .description('Fetch symbols')
37
+ .action(async (source, destination) => {
38
+ const response = await fetch(DEFAULT_CONFIG)
39
+ const body = await response.json()
40
+ const { version, ...config } = body
41
+
42
+ console.log('')
43
+ console.log(chalk.bold('Symbols'), 'config received: ', chalk.green(version))
44
+
45
+ const path = process.cwd() + '/.symbolsrc.json'
46
+ console.log(chalk.dim('Default config fetched: '), chalk.dim.underline(path))
47
+ console.log('')
48
+
49
+ fs.writeFile(path, JSON.stringify(body), err => {
50
+ if (err) {
51
+ console.log('Error writing file', err)
52
+ } else {
53
+ console.log('Successfully wrote file')
54
+ }
55
+ })
56
+
57
+ for (const t in config) {
58
+ const type = config[t]
59
+ console.log(chalk.bold(t))
60
+ // for (const v in type) console.log(' ', chalk.dim(v))
61
+ console.log(Object.keys(type))
62
+ }
63
+ })
64
+
65
+ var args = process.argv
66
+ program.parse(args)
package/package.json CHANGED
@@ -1,5 +1,25 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "0.6.4",
4
- "license": "MIT"
3
+ "version": "0.6.9",
4
+ "description": "Fetch your Symbols configuration",
5
+ "main": "index.js",
6
+ "author": "Symbols",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "type": "module",
10
+ "bin": {
11
+ "symbo-ls": "bin/fetch.js"
12
+ },
13
+ "scripts": {
14
+ "start": "node bin/fetch.js"
15
+ },
16
+ "dependencies": {
17
+ "chalk": "^5.0.0",
18
+ "node-fetch": "^3.1.0"
19
+ },
20
+ "devDependencies": {
21
+ "commander": "^8.3.0",
22
+ "v8-compile-cache": "^2.3.0"
23
+ },
24
+ "gitHead": "fa58769cac66c692cb8d39d37a51d017586dde57"
5
25
  }