@symbo.ls/cli 2.11.39 → 2.11.41
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 +14 -5
- package/package.json +2 -2
package/bin/convert.js
CHANGED
|
@@ -64,6 +64,7 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
64
64
|
console.group()
|
|
65
65
|
const uniqueImports = []
|
|
66
66
|
let first = true
|
|
67
|
+
let currentExportIdx = 0
|
|
67
68
|
let removeUseContextImport = false
|
|
68
69
|
const exportCount = Object.keys(domqlModule).length
|
|
69
70
|
for (const key in domqlModule) {
|
|
@@ -86,20 +87,28 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
86
87
|
const component = domqlModule[key]
|
|
87
88
|
component.__name = key
|
|
88
89
|
|
|
90
|
+
const isSingleComponent = exportCount === 1
|
|
91
|
+
const isFirst = currentExportIdx === 0
|
|
92
|
+
const isLast = currentExportIdx === exportCount - 1
|
|
93
|
+
|
|
89
94
|
const out = convert(component, desiredFormat, {
|
|
90
95
|
verbose: false,
|
|
91
|
-
exportDefault:
|
|
96
|
+
exportDefault: isSingleComponent,
|
|
92
97
|
returnMitosisIR: true,
|
|
93
98
|
importsToRemove: uniqueImports,
|
|
94
|
-
removeReactImport: !
|
|
99
|
+
removeReactImport: !isFirst,
|
|
95
100
|
removeUseContextImport
|
|
96
101
|
})
|
|
97
102
|
|
|
98
|
-
convertedStr = convertedStr + out.str
|
|
103
|
+
convertedStr = convertedStr + out.str
|
|
104
|
+
if (options.trailingNewLine && !isLast) {
|
|
105
|
+
convertedStr += '\n'
|
|
106
|
+
}
|
|
107
|
+
|
|
99
108
|
uniqueImports.push(...out.mitosisIR.imports)
|
|
100
|
-
first = false
|
|
101
109
|
if (out.mitosisIR._useContext) { removeUseContextImport = true }
|
|
102
110
|
console.groupEnd()
|
|
111
|
+
currentExportIdx++
|
|
103
112
|
} else {
|
|
104
113
|
throw new Error('Convert from `domql-to-mitosis` is not defined. Try to install `domql-to-mitosis` and run this command again.')
|
|
105
114
|
}
|
|
@@ -260,7 +269,7 @@ program
|
|
|
260
269
|
const convertedStr = convertDomqlModule(
|
|
261
270
|
domqlModule,
|
|
262
271
|
desiredFormat,
|
|
263
|
-
options
|
|
272
|
+
{...options, trailingNewLine: true }
|
|
264
273
|
)
|
|
265
274
|
|
|
266
275
|
// Write file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/cli",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.41",
|
|
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": "16a11ea1e0d141165130ac295dcdd80728d8c492"
|
|
31
31
|
}
|