@symbo.ls/cli 0.6.7 → 0.6.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/bin/fetch.js CHANGED
@@ -1,45 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import 'v8-compile-cache'
4
- import { createRequire } from 'module'
4
+ import { loadModule } from './require.js'
5
5
  import { Command } from 'commander'
6
6
  import fetch from 'node-fetch'
7
7
  import chalk from 'chalk'
8
8
 
9
- const require = createRequire(import.meta.url)
10
- const pkg = require('../package.json')
9
+ const pkg = loadModule('../package.json')
11
10
  const program = new Command()
12
11
 
13
- const API_URL = 'https://api.symbols.app/'
12
+ const API_URL = 'https://api.symbols.app/' // eslint-disable-line
14
13
  const DEFAULT_CONFIG = 'https://raw.githubusercontent.com/symbo-ls/uikit/8e7026a2216c68efad260961a77c9302d34c7aa4/packages/config-default/src/config.json'
15
14
 
16
15
  program
17
16
  .version(pkg.version)
18
17
 
19
- program
20
- .command('login [destination]')
21
- .description('Sign in to Symbols')
22
- .argument('<username>', 'user to login')
23
- .argument('[password]', 'password for user, if required', 'no password given')
24
- .action(async (username, password) => {
25
- console.log('username:', username)
26
- console.log('password:', password)
27
-
28
- const response = await fetch(API_URL)
29
- const body = await response.json()
30
- console.log(body)
31
- })
32
-
33
18
  program
34
19
  .command('fetch [destination]')
35
20
  .description('Fetch symbols')
36
21
  .action(async (source, destination) => {
37
22
  const response = await fetch(DEFAULT_CONFIG)
38
- const body = await response.text()
39
- const parsed = JSON.parse(body)
40
- const { version, ...config } = parsed
23
+ const body = await response.json()
24
+ const { version, ...config } = body
25
+
41
26
  console.log('')
42
27
  console.log(chalk.bold('Symbols'), 'config received: ', chalk.green(version))
28
+
29
+ const path = process.cwd() + '/.symbolsrc.json'
30
+ console.log(chalk.dim('Default config fetched: '), chalk.dim.underline(path))
31
+ console.log('')
32
+
33
+ fs.writeFile(path, JSON.stringify(body), err => {
34
+ if (err) {
35
+ console.log('Error writing file', err)
36
+ } else {
37
+ console.log('Successfully wrote file')
38
+ }
39
+ })
40
+
43
41
  for (const t in config) {
44
42
  const type = config[t]
45
43
  console.log(chalk.bold(t))
package/bin/login.js ADDED
@@ -0,0 +1,15 @@
1
+ 'use strict'
2
+
3
+ program
4
+ .command('login [destination]')
5
+ .description('Sign in to Symbols')
6
+ .argument('<username>', 'user to login')
7
+ .argument('[password]', 'password for user, if required', 'no password given')
8
+ .action(async (username, password) => {
9
+ console.log('username:', username)
10
+ console.log('password:', password)
11
+
12
+ const response = await fetch(API_URL)
13
+ const body = await response.json()
14
+ console.log(body)
15
+ })
package/bin/require.js ADDED
@@ -0,0 +1,9 @@
1
+ class ImportError extends Error {}
2
+
3
+ export const loadModule = async (modulePath) => {
4
+ try {
5
+ return await import(modulePath)
6
+ } catch (e) {
7
+ throw new ImportError(`Unable to import module ${modulePath}`)
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "0.6.7",
3
+ "version": "0.6.11",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "index.js",
6
6
  "author": "Symbols",
@@ -11,15 +11,21 @@
11
11
  "symbo-ls": "bin/fetch.js"
12
12
  },
13
13
  "scripts": {
14
- "start": "node bin/fetch.js"
14
+ "start": "node bin/fetch.js",
15
+ "vpush": "git add . && git commit -am 'version update' && git push",
16
+ "vpatch": "npm version patch && npm publish"
15
17
  },
16
18
  "dependencies": {
17
19
  "chalk": "^5.0.0",
18
- "node-fetch": "^3.1.0"
19
- },
20
- "devDependencies": {
20
+ "node-fetch": "^3.1.0",
21
21
  "commander": "^8.3.0",
22
22
  "v8-compile-cache": "^2.3.0"
23
23
  },
24
+ "devDependencies": {
25
+ "np": "^7.6.0"
26
+ },
27
+ "env": {
28
+ "process": true
29
+ },
24
30
  "gitHead": "6123989a3672237d094929300016f72da7edf822"
25
31
  }