@symbo.ls/cli 2.11.21 → 2.11.25
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 +37 -30
- package/package.json +2 -2
package/bin/convert.js
CHANGED
|
@@ -59,6 +59,7 @@ async function importDomqlModule (modulePath) {
|
|
|
59
59
|
|
|
60
60
|
function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
61
61
|
let convertedStr = ''
|
|
62
|
+
const whitelist = (options.only ? options.only.split(',') : null)
|
|
62
63
|
|
|
63
64
|
console.group()
|
|
64
65
|
const uniqueImports = []
|
|
@@ -66,41 +67,46 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
66
67
|
let removeUseContextImport = false
|
|
67
68
|
const exportCount = Object.keys(domqlModule).length
|
|
68
69
|
for (const key in domqlModule) {
|
|
70
|
+
// Skip if not found in whitelist
|
|
71
|
+
if (whitelist && !whitelist.includes(key))
|
|
72
|
+
continue
|
|
73
|
+
|
|
74
|
+
// Skip some components if converting smbls uikit
|
|
69
75
|
if (options.internalUikit &&
|
|
70
76
|
EXCLUDED_FROM_INTERNAL_UIKIT.includes(key)) {
|
|
71
77
|
console.log(`Skipping ${key} component due to exclusion`)
|
|
72
78
|
continue
|
|
73
79
|
}
|
|
80
|
+
|
|
74
81
|
console.log(key)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// }
|
|
82
|
+
try {
|
|
83
|
+
// import('domql-to-mitosis').then(({ convert }) => {
|
|
84
|
+
if (convert) {
|
|
85
|
+
console.group()
|
|
86
|
+
const component = domqlModule[key]
|
|
87
|
+
component.__name = key
|
|
88
|
+
|
|
89
|
+
const out = convert(component, desiredFormat, {
|
|
90
|
+
verbose: false,
|
|
91
|
+
exportDefault: exportCount === 1,
|
|
92
|
+
returnMitosisIR: true,
|
|
93
|
+
importsToRemove: uniqueImports,
|
|
94
|
+
removeReactImport: !first,
|
|
95
|
+
removeUseContextImport
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
convertedStr = convertedStr + out.str + '\n'
|
|
99
|
+
uniqueImports.push(...out.mitosisIR.imports)
|
|
100
|
+
first = false
|
|
101
|
+
if (out.mitosisIR._useContext) { removeUseContextImport = true }
|
|
102
|
+
console.groupEnd()
|
|
103
|
+
} else {
|
|
104
|
+
throw new Error('Convert from `domql-to-mitosis` is not defined. Try to install `domql-to-mitosis` and run this command again.')
|
|
105
|
+
}
|
|
106
|
+
// })
|
|
107
|
+
} catch (err) {
|
|
108
|
+
throw new Error('`domql-to-mitosis` is not found.')
|
|
109
|
+
}
|
|
104
110
|
}
|
|
105
111
|
console.groupEnd()
|
|
106
112
|
|
|
@@ -116,8 +122,9 @@ program
|
|
|
116
122
|
.option('--angular', 'Convert all DomQL components to Angular')
|
|
117
123
|
.option('--vue2', 'Convert all DomQL components to Vue2')
|
|
118
124
|
.option('--vue3', 'Convert all DomQL components to Vue3')
|
|
125
|
+
.option('-t, --tmp-dir <path>', `Use this directory for storing intermediate & build files instead of the default (dest/${TMP_DIR_NAME})`)
|
|
126
|
+
.option('-o, --only <components>', `Only convert these components; comma separated (for example: --only=Flex,Img)`)
|
|
119
127
|
.option('--internal-uikit', '(For internal use only). Excludes particular components from the conversion')
|
|
120
|
-
.option('--tmp-dir', `Use this directory for storing intermediate & build files instead of the default (dest/${TMP_DIR_NAME})`)
|
|
121
128
|
.action(async (src, dest, options) => {
|
|
122
129
|
// Desired format
|
|
123
130
|
let desiredFormat = 'react'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/cli",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.25",
|
|
4
4
|
"description": "Fetch your Symbols configuration",
|
|
5
5
|
"main": "bin/fetch.js",
|
|
6
6
|
"author": "Symbols",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"domql-to-mitosis": "latest"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "920a0a24e71053cd1e83cfbd8ee4bd4534f516d6"
|
|
31
31
|
}
|