@symbo.ls/cli 2.10.107 → 2.10.120

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/convert.js CHANGED
@@ -3,56 +3,84 @@
3
3
  import * as esbuild from 'esbuild'
4
4
  import { loadModule } from './require.js'
5
5
  import { program } from './program.js'
6
- import { convert } from 'domql-to-mitosis/asd/convert.js'
6
+ import { convert } from 'domql-to-mitosis'
7
7
  import fs from 'fs'
8
8
  import path from 'path'
9
+ import { JSDOM } from 'jsdom'
10
+
11
+ const jsdom = new JSDOM(`<html><head></head><body></body></html>`)
12
+ global.window = jsdom.window
13
+ global.document = window.document
9
14
 
10
15
  const TMP_DIR_NAME = ".smbls_convert_tmp"
11
16
 
12
17
  program
13
- .command('convert')
14
- .description('Recursively convert and copy all DomQL components under a directory')
15
- .argument('[src]', 'Source directory. By default, it is "."', '.')
16
- .argument('[dest]', 'Destination directory. By default, it becomes the name of the desired format')
17
- .option('--react', 'Convert all DomQL components to React')
18
- .option('--angular', 'Convert all DomQL components to Angular')
19
- .option('--vue2', 'Convert all DomQL components to Vue2')
20
- .option('--vue3', 'Convert all DomQL components to Vue3')
21
- .action(async (src, dest, options) => {
22
- const srcPath = path.resolve(src)
23
- const destPath = path.resolve(dest || 'asd')
24
- const tmpDirPath = path.resolve(path.dirname(destPath), TMP_DIR_NAME)
25
-
26
- await fs.mkdir(tmpDirPath, async () => {
27
- const origFiles = await fs.promises.readdir(srcPath)
28
- console.log(origFiles)
29
-
30
- await esbuild.build({
31
- entryPoints: origFiles.map(file => path.join(srcPath, file, '/index.js')),
32
- bundle: true,
33
- target: 'node12',
34
- format: 'cjs',
35
- outdir: tmpDirPath
36
- })
37
-
38
- const files = await fs.promises.readdir(tmpDirPath)
39
- for (const file of files) {
40
- if (file === 'atoms') continue
41
-
42
- let filePath = path.join(tmpDirPath, file)
43
-
44
- if ((await fs.promises.stat(filePath)).isDirectory()) {
45
- console.log(`importing ${filePath}`)
46
- const domqlModule = (await import(`${filePath}/index.js`)).default
47
- console.log(domqlModule)
48
- for (const key in domqlModule) {
49
- const component = domqlModule[key]
50
- console.group(key)
51
- console.log('========================', key)
52
- convert(component, 'react')
53
- console.groupEnd(key)
54
- }
55
- }
18
+ .command('convert')
19
+ .description('Recursively convert and copy all DomQL components under a directory')
20
+ .argument('[src]', 'Source directory. By default, it is "."', '.')
21
+ .argument('[dest]', 'Destination directory. By default, it becomes the name of the desired format')
22
+ .option('--react', 'Convert all DomQL components to React')
23
+ .option('--angular', 'Convert all DomQL components to Angular')
24
+ .option('--vue2', 'Convert all DomQL components to Vue2')
25
+ .option('--vue3', 'Convert all DomQL components to Vue3')
26
+ .action(async (src, dest, options) => {
27
+ // Desired format
28
+ let desiredFormat = 'react'
29
+ if (options.angular) {
30
+ desiredFormat = 'angular'
31
+ } else if (options.vue2) {
32
+ desiredFormat = 'vue2'
33
+ } else if (options.vue3) {
34
+ desiredFormat = 'vue3'
35
+ }
36
+
37
+ // Resolve source & destination directories
38
+ const srcPath = path.resolve(src || './src')
39
+ const destPath = path.resolve(dest || './dist')
40
+ const tmpDirPath = path.resolve(path.dirname(destPath), TMP_DIR_NAME)
41
+
42
+ // Make tmp directory
43
+ try {
44
+ await fs.promises.mkdir(tmpDirPath)
45
+ } catch (err) {
46
+ if (err.code !== 'EEXIST') {
47
+ console.log(err)
48
+ return 1;
49
+ }
50
+ }
51
+
52
+ const origFiles = await fs.promises.readdir(srcPath)
53
+
54
+ // Bundle components
55
+ await esbuild.build({
56
+ entryPoints: origFiles.map(file => path.join(srcPath, file, '/index.js')),
57
+ bundle: true,
58
+ sourcemap: true,
59
+ target: 'node12',
60
+ format: 'cjs',
61
+ outdir: tmpDirPath
62
+ })
63
+
64
+ // Convert components
65
+ const files = await fs.promises.readdir(tmpDirPath)
66
+ for (const file of files) {
67
+ if (file === 'Atoms') continue
68
+
69
+ let filePath = path.join(tmpDirPath, file)
70
+
71
+ if ((await fs.promises.stat(filePath)).isDirectory()) {
72
+ const importPath = `${filePath}/index.js`
73
+ console.log(`importing ${importPath}`)
74
+ const domqlModule = (await import(importPath)).default
75
+ console.log(domqlModule)
76
+ for (const key in domqlModule) {
77
+ const component = domqlModule[key]
78
+ const gen = convert(component, desiredFormat, {
79
+ verbose: false,
80
+ exportDefault: domqlModule.length === 1
81
+ })
82
+ //console.log(gen)
56
83
  }
57
- })
58
- })
84
+ }
85
+ }
86
+ })
package/bin/fetch.js CHANGED
@@ -8,12 +8,12 @@ import { exec } from 'child_process'
8
8
  import { program } from './program.js'
9
9
 
10
10
  const PACKAGE_PATH = process.cwd() + '/package.json'
11
- const RC_PATH = process.cwd() + '/.symbolsrc.json'
11
+ const RC_PATH = process.cwd() + '/symbols.json'
12
12
  const LOCAL_CONFIG_PATH = process.cwd() + '/node_modules/@symbo.ls/init/dynamic.json'
13
13
  const DEFAULT_REMOTE_REPOSITORY = 'https://github.com/symbo-ls/default-config/'
14
14
  const DEFAULT_REMOTE_CONFIG_PATH = 'https://raw.githubusercontent.com/symbo-ls/default-config/main/src/config.json'
15
15
 
16
- const API_URL = 'https://api.symbols.app/' // eslint-disable-line
16
+ const API_URL = 'https://api.symbols.dev/' // eslint-disable-line
17
17
 
18
18
  const pkg = loadModule(PACKAGE_PATH)
19
19
  const rc_file = loadModule(RC_PATH) // eslint-disable-line
@@ -58,9 +58,10 @@ program
58
58
  console.log('\n')
59
59
  console.log(chalk.green.bold(packageName), 'successfuly added!')
60
60
  console.log('')
61
- console.log(chalk.dim('Now you can import components like:'), `import { Button } from "${chalk.green.bold(packageName)}"`)
61
+ console.log(chalk.dim('Now you can import components like:'), `import { Button } from 'smbls`)
62
62
  })
63
63
  })
64
+
64
65
  program
65
66
  .command('fetch [destination]')
66
67
  .description('Fetch symbols')
@@ -73,7 +74,7 @@ program
73
74
  console.log('')
74
75
  console.log(chalk.bold('Symbols'), 'config fetched:', chalk.green(version))
75
76
 
76
- console.log(chalk.dim('- .symbolsrc.json created:'), chalk.dim.underline(LOCAL_CONFIG_PATH))
77
+ console.log(chalk.dim('- symbols.json created:'), chalk.dim.underline(LOCAL_CONFIG_PATH))
77
78
  console.log('')
78
79
 
79
80
  const bodyString = JSON.stringify(body)
package/bin/index.js CHANGED
@@ -7,6 +7,7 @@ import './init.js'
7
7
  import './fetch.js'
8
8
  import './sync.js'
9
9
  import './clean.js'
10
+ import './convert.js'
10
11
 
11
12
  const args = process.argv
12
- program.parse(args)
13
+ program.parse(args)
package/bin/link-all.js CHANGED
@@ -1,21 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { sync } from '@symbo.ls/socket'
4
3
  import { program } from './program.js'
5
- import { loadModule } from './require.js'
6
-
7
- const RC_PATH = process.cwd() + '/.symbolsrc.json'
8
- let rc = {}
9
- try {
10
- rc = loadModule(RC_PATH) // eslint-disable-line
11
- } catch (e) { console.error('Please include .symbolsrc.json to your root of respository') }
12
4
 
13
5
  program
14
6
  .command('link-all')
15
7
  .description('Symlink all smbls dependencies')
16
8
  .action(async (options) => {
17
- rc.then(data => {
18
- const opts = { ...data, ...options }
19
- sync(null, opts)
20
- })
9
+ //
21
10
  })
@@ -4,11 +4,11 @@ import { sync } from '@symbo.ls/socket'
4
4
  import { program } from './program.js'
5
5
  import { loadModule } from './require.js'
6
6
 
7
- const RC_PATH = process.cwd() + '/.symbolsrc.json'
7
+ const RC_PATH = process.cwd() + '/symbols.json'
8
8
  let rc = {}
9
9
  try {
10
10
  rc = loadModule(RC_PATH) // eslint-disable-line
11
- } catch (e) { console.error('Please include .symbolsrc.json to your root of respository') }
11
+ } catch (e) { console.error('Please include symbols.json to your root of respository') }
12
12
 
13
13
  program
14
14
  .command('socket-server')
package/bin/sync.js CHANGED
@@ -4,13 +4,11 @@ import * as asd from '@symbo.ls/socket/client.js'
4
4
  import { program } from './program.js'
5
5
  import { loadModule } from './require.js'
6
6
 
7
- console.log(asd)
8
-
9
- const RC_PATH = process.cwd() + '/.symbolsrc.json'
7
+ const RC_PATH = process.cwd() + '/symbols.json'
10
8
  let rc = {}
11
9
  try {
12
10
  rc = loadModule(RC_PATH) // eslint-disable-line
13
- } catch (e) { console.error('Please include .symbolsrc.json to your root of respository') }
11
+ } catch (e) { console.error('Please include symbols.json to your root of respository') }
14
12
 
15
13
  program
16
14
  .command('sync')
@@ -21,7 +19,6 @@ program
21
19
  rc.then(data => {
22
20
  const opts = { ...data, ...options }
23
21
  const key = rc.key || options.key
24
- console.log(opts)
25
22
  asd.connect(key, {
26
23
  socketUrl: 'socket.symbols.app',
27
24
  onConnect: (id, socket) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.10.107",
3
+ "version": "2.10.120",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "bin/fetch.js",
6
6
  "author": "Symbols",
@@ -18,10 +18,14 @@
18
18
  "@symbo.ls/init": "latest",
19
19
  "@symbo.ls/socket": "latest",
20
20
  "chalk": "^5.0.0",
21
- "commander": "^9.4.1",
21
+ "commander": "latest",
22
22
  "esbuild": "latest",
23
+ "jsdom": "^21.1.0",
23
24
  "node-fetch": "^3.1.0",
24
25
  "v8-compile-cache": "^2.3.0"
25
26
  },
26
- "gitHead": "5bfdec0a855ab8c1a7e05b16697dc8aeb4d878f8"
27
+ "standard": {
28
+ "parser": "babel-eslint"
29
+ },
30
+ "gitHead": "6855dfed4db71595cba43e5ceb414765cf35b99f"
27
31
  }
package/README.md DELETED
@@ -1,11 +0,0 @@
1
- # CLI tool for Symbols
2
-
3
- Yarn:
4
- ```
5
- smbls fetch
6
- ```
7
-
8
- or via NPM:
9
- ```
10
- npx smbls fetch
11
- ```