@symbo.ls/cli 2.11.61 → 2.11.70
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 +25 -19
- package/package.json +2 -2
package/bin/convert.js
CHANGED
|
@@ -65,7 +65,6 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
65
65
|
const uniqueImports = []
|
|
66
66
|
const first = true
|
|
67
67
|
let currentExportIdx = 0
|
|
68
|
-
let removeUseContextImport = false
|
|
69
68
|
const exportCount = Object.keys(domqlModule).length
|
|
70
69
|
for (const key in domqlModule) {
|
|
71
70
|
// Skip if not found in whitelist
|
|
@@ -78,16 +77,11 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
78
77
|
continue
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
try {
|
|
82
|
-
convert()
|
|
83
|
-
} catch (err) {
|
|
84
|
-
throw new Error('`domql-to-mitosis` is not found.')
|
|
85
|
-
}
|
|
86
|
-
// import('domql-to-mitosis').then(({ convert }) => {
|
|
87
80
|
if (convert) {
|
|
88
81
|
console.group()
|
|
89
82
|
const component = domqlModule[key]
|
|
90
83
|
component.__name = key
|
|
84
|
+
console.log(key) // NOTE: @nikoloza don't remove this (again)
|
|
91
85
|
|
|
92
86
|
const isSingleComponent = exportCount === 1
|
|
93
87
|
const isFirst = currentExportIdx === 0
|
|
@@ -98,8 +92,7 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
98
92
|
exportDefault: isSingleComponent,
|
|
99
93
|
returnMitosisIR: true,
|
|
100
94
|
importsToRemove: uniqueImports,
|
|
101
|
-
removeReactImport: !isFirst
|
|
102
|
-
removeUseContextImport
|
|
95
|
+
removeReactImport: !isFirst
|
|
103
96
|
})
|
|
104
97
|
|
|
105
98
|
convertedStr = convertedStr + out.str
|
|
@@ -108,11 +101,12 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
uniqueImports.push(...out.mitosisIR.imports)
|
|
111
|
-
if (out.mitosisIR._useContext) { removeUseContextImport = true }
|
|
112
104
|
console.groupEnd()
|
|
113
105
|
currentExportIdx++
|
|
114
106
|
} else {
|
|
115
|
-
throw new Error(
|
|
107
|
+
throw new Error(
|
|
108
|
+
'Convert from `domql-to-mitosis` is not defined. Try to install' +
|
|
109
|
+
'`domql-to-mitosis` and run this command again.')
|
|
116
110
|
}
|
|
117
111
|
}
|
|
118
112
|
console.groupEnd()
|
|
@@ -122,16 +116,24 @@ function convertDomqlModule (domqlModule, desiredFormat, options) {
|
|
|
122
116
|
|
|
123
117
|
program
|
|
124
118
|
.command('convert')
|
|
125
|
-
.description('
|
|
119
|
+
.description('Convert and copy all DomQL components under a directory')
|
|
126
120
|
.argument('[src]', 'Source directory/file. By default, it is "src/"')
|
|
127
|
-
.argument('[dest]',
|
|
121
|
+
.argument('[dest]',
|
|
122
|
+
'Destination directory/file. Will be overwritten. By ' +
|
|
123
|
+
'default, it becomes the name of the desired format')
|
|
128
124
|
.option('--react', 'Convert all DomQL components to React')
|
|
129
125
|
.option('--angular', 'Convert all DomQL components to Angular')
|
|
130
126
|
.option('--vue2', 'Convert all DomQL components to Vue2')
|
|
131
127
|
.option('--vue3', 'Convert all DomQL components to Vue3')
|
|
132
|
-
.option('-t, --tmp-dir <path>',
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
.option('-t, --tmp-dir <path>',
|
|
129
|
+
'Use this directory for storing intermediate & build files instead of ' +
|
|
130
|
+
`the default (dest/${TMP_DIR_NAME})`)
|
|
131
|
+
.option('-o, --only <components>',
|
|
132
|
+
'Only convert these components; comma separated ' +
|
|
133
|
+
'(for example: --only=Flex,Img)')
|
|
134
|
+
.option('--internal-uikit',
|
|
135
|
+
'(For internal use only). ' +
|
|
136
|
+
'Excludes particular components from the conversion')
|
|
135
137
|
.action(async (src, dest, options) => {
|
|
136
138
|
// Desired format
|
|
137
139
|
let desiredFormat = 'react'
|
|
@@ -159,7 +161,8 @@ program
|
|
|
159
161
|
// Put a package.json file so that when we import() the modules from the
|
|
160
162
|
// directory, node doesn't recognize them as ES modules (in case the parent
|
|
161
163
|
// directory of the tmp dir has "type": "module" in its package.json
|
|
162
|
-
const pj = await fs.promises.open(
|
|
164
|
+
const pj = await fs.promises.open(
|
|
165
|
+
path.resolve(tmpDirPath, 'package.json'), 'w')
|
|
163
166
|
await pj.writeFile(TMP_DIR_PACKAGE_JSON_STR, 'utf8')
|
|
164
167
|
await pj.close()
|
|
165
168
|
|
|
@@ -233,7 +236,9 @@ program
|
|
|
233
236
|
destDirPath = path.resolve(dest)
|
|
234
237
|
} else {
|
|
235
238
|
// dest exists and is not a directory.
|
|
236
|
-
console.error(
|
|
239
|
+
console.error(
|
|
240
|
+
`The destination ('${path.resolve(dest)}') must be a directory when` +
|
|
241
|
+
`the source ('${srcPath}') is a directory`)
|
|
237
242
|
return 1
|
|
238
243
|
}
|
|
239
244
|
|
|
@@ -242,7 +247,8 @@ program
|
|
|
242
247
|
|
|
243
248
|
// Bundle components
|
|
244
249
|
await esbuild.build({
|
|
245
|
-
entryPoints: origFiles.map(file =>
|
|
250
|
+
entryPoints: origFiles.map(file =>
|
|
251
|
+
path.join(srcPath, file,'./index.js')),
|
|
246
252
|
bundle: true,
|
|
247
253
|
sourcemap: true,
|
|
248
254
|
target: 'node12',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/cli",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.70",
|
|
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": "329c180a4cf02896ec76566a5b2f5368f62a6b06"
|
|
31
31
|
}
|