@symbo.ls/cli 2.11.39 → 2.11.56

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 +37 -30
  2. package/package.json +2 -2
package/bin/convert.js CHANGED
@@ -63,13 +63,13 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
63
63
 
64
64
  console.group()
65
65
  const uniqueImports = []
66
- let first = true
66
+ const 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) {
70
71
  // Skip if not found in whitelist
71
- if (whitelist && !whitelist.includes(key))
72
- continue
72
+ if (whitelist && !whitelist.includes(key)) { continue }
73
73
 
74
74
  // Skip some components if converting smbls uikit
75
75
  if (options.internalUikit &&
@@ -78,35 +78,42 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
78
78
  continue
79
79
  }
80
80
 
81
- console.log(key)
82
81
  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
- // })
82
+ convert()
107
83
  } catch (err) {
108
84
  throw new Error('`domql-to-mitosis` is not found.')
109
85
  }
86
+ // import('domql-to-mitosis').then(({ convert }) => {
87
+ if (convert) {
88
+ console.group()
89
+ const component = domqlModule[key]
90
+ component.__name = key
91
+
92
+ const isSingleComponent = exportCount === 1
93
+ const isFirst = currentExportIdx === 0
94
+ const isLast = currentExportIdx === exportCount - 1
95
+
96
+ const out = convert(component, desiredFormat, {
97
+ verbose: false,
98
+ exportDefault: isSingleComponent,
99
+ returnMitosisIR: true,
100
+ importsToRemove: uniqueImports,
101
+ removeReactImport: !isFirst,
102
+ removeUseContextImport
103
+ })
104
+
105
+ convertedStr = convertedStr + out.str
106
+ if (options.trailingNewLine && !isLast) {
107
+ convertedStr += '\n'
108
+ }
109
+
110
+ uniqueImports.push(...out.mitosisIR.imports)
111
+ if (out.mitosisIR._useContext) { removeUseContextImport = true }
112
+ console.groupEnd()
113
+ currentExportIdx++
114
+ } else {
115
+ throw new Error('Convert from `domql-to-mitosis` is not defined. Try to install `domql-to-mitosis` and run this command again.')
116
+ }
110
117
  }
111
118
  console.groupEnd()
112
119
 
@@ -123,7 +130,7 @@ program
123
130
  .option('--vue2', 'Convert all DomQL components to Vue2')
124
131
  .option('--vue3', 'Convert all DomQL components to Vue3')
125
132
  .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)`)
133
+ .option('-o, --only <components>', 'Only convert these components; comma separated (for example: --only=Flex,Img)')
127
134
  .option('--internal-uikit', '(For internal use only). Excludes particular components from the conversion')
128
135
  .action(async (src, dest, options) => {
129
136
  // Desired format
@@ -260,7 +267,7 @@ program
260
267
  const convertedStr = convertDomqlModule(
261
268
  domqlModule,
262
269
  desiredFormat,
263
- options
270
+ { ...options, trailingNewLine: true }
264
271
  )
265
272
 
266
273
  // Write file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.11.39",
3
+ "version": "2.11.56",
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": "2f40754c45ab3e9132e5335d3f01fcf7d2ac977b"
30
+ "gitHead": "f69acac1d0a3b53b8c6d7caac06964b830174cec"
31
31
  }