@symbo.ls/cli 2.10.49 → 2.10.60

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/convert.js +58 -0
  2. package/package.json +2 -2
package/bin/convert.js ADDED
@@ -0,0 +1,58 @@
1
+ 'use strict'
2
+
3
+ import * as esbuild from 'esbuild'
4
+ import { loadModule } from './require.js'
5
+ import { program } from './program.js'
6
+ import { convert } from 'domql-to-mitosis/asd/convert.js'
7
+ import fs from 'fs'
8
+ import path from 'path'
9
+
10
+ const TMP_DIR_NAME = ".smbls_convert_tmp"
11
+
12
+ 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
+ }
56
+ }
57
+ })
58
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.10.49",
3
+ "version": "2.10.60",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "bin/fetch.js",
6
6
  "author": "Symbols",
@@ -26,5 +26,5 @@
26
26
  "standard": {
27
27
  "parser": "babel-eslint"
28
28
  },
29
- "gitHead": "6c85785f0f1488d8d20595000faa787994aea2dc"
29
+ "gitHead": "97cdca33752e544e05a1bcb6e549ed7c4737106d"
30
30
  }