@symbo.ls/cli 2.11.60 → 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/bin/create.js +7 -1
- package/bin/init-helpers/DesignSystem.js +13 -12
- package/bin/init-helpers/addToJson.js +28 -0
- package/bin/init-helpers/init-repo.js +32 -7
- package/bin/init-helpers/symbols.json +3 -0
- package/bin/init.js +5 -5
- 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/bin/create.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import chalk from 'chalk'
|
|
4
4
|
import fs from 'fs'
|
|
5
|
+
import path from 'path'
|
|
5
6
|
import { execSync } from 'child_process'
|
|
6
7
|
import { program } from './program.js'
|
|
8
|
+
import { addToJson } from './init-helpers/addToJson.js'
|
|
7
9
|
|
|
8
10
|
function folderExists (path) {
|
|
9
11
|
try {
|
|
@@ -31,7 +33,7 @@ program
|
|
|
31
33
|
.option('--angular', 'Use Angular in the project')
|
|
32
34
|
.option('--vue2', 'Use Vue2 in the project')
|
|
33
35
|
.option('--vue3', 'Use Vue3 in the project')
|
|
34
|
-
.action(async (dest, options) => {
|
|
36
|
+
.action(async (dest = 'symbols-starter-kit', options) => {
|
|
35
37
|
// Determine framework
|
|
36
38
|
let framework = 'domql'
|
|
37
39
|
if (options.react) {
|
|
@@ -54,6 +56,10 @@ program
|
|
|
54
56
|
execSync(`git clone ${cloneUrl} ${dest}`)
|
|
55
57
|
|
|
56
58
|
process.chdir(dest)
|
|
59
|
+
|
|
60
|
+
const SYMBOLS_FILE_PATH = path.join(process.cwd(), 'symbols.json')
|
|
61
|
+
addToJson(SYMBOLS_FILE_PATH, 'key', `${dest}.symbo.ls`)
|
|
62
|
+
|
|
57
63
|
console.log('Installing Dependencies...')
|
|
58
64
|
console.log()
|
|
59
65
|
execSync('npm i')
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export const CustomDesignSystem = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
ANIMATION: {},
|
|
3
|
+
COLOR: {},
|
|
4
|
+
GRADIENT: {},
|
|
5
|
+
THEME: {},
|
|
6
|
+
TYPOGRAPHY: {},
|
|
7
|
+
SPACING: {},
|
|
8
|
+
SVG: {},
|
|
9
|
+
ICONS: {},
|
|
10
|
+
FONT: {},
|
|
11
|
+
FONT_FAMILY: {},
|
|
12
|
+
TIMING: {},
|
|
13
|
+
MEDIA: {},
|
|
14
|
+
RESET: {}
|
|
14
15
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
|
|
5
|
+
// Step 1: Read the JSON file
|
|
6
|
+
export const addToJson = (filePath, key, value) => {
|
|
7
|
+
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
8
|
+
if (err) {
|
|
9
|
+
console.error('Error reading file:', err)
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const jsonData = JSON.parse(data)
|
|
15
|
+
|
|
16
|
+
jsonData[key] = value
|
|
17
|
+
|
|
18
|
+
fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 2), 'utf8', err => {
|
|
19
|
+
if (err) {
|
|
20
|
+
console.error('Error writing file:', err)
|
|
21
|
+
}
|
|
22
|
+
console.log(filePath, JSON.stringify(jsonData, null, 2))
|
|
23
|
+
})
|
|
24
|
+
} catch (parseError) {
|
|
25
|
+
console.error('Error parsing JSON:', parseError)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import chalk from 'chalk'
|
|
4
4
|
import fs from 'fs'
|
|
5
5
|
import path from 'path'
|
|
6
|
+
import { execSync } from 'child_process'
|
|
6
7
|
import { fileURLToPath } from 'url'
|
|
8
|
+
import { addToJson } from './addToJson.js'
|
|
9
|
+
|
|
7
10
|
const __filename = fileURLToPath(import.meta.url)
|
|
8
11
|
const __dirname = path.dirname(__filename)
|
|
12
|
+
const SYMBOLS_FILE_PATH = path.join(
|
|
13
|
+
__dirname, 'symbols.json')
|
|
9
14
|
const DESIGN_SYSTEM_FILE_PATH = path.join(
|
|
10
15
|
__dirname, 'DesignSystem.js')
|
|
11
16
|
|
|
@@ -20,18 +25,38 @@ export async function initRepo (dest, framework) {
|
|
|
20
25
|
process.chdir(cwd)
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
// Determine framework
|
|
29
|
+
let pkg = 'smbls'
|
|
30
|
+
if (framework === 'react') {
|
|
31
|
+
pkg = '@symbo.ls/react'
|
|
32
|
+
} else if (framework === 'angular') {
|
|
33
|
+
pkg = '@symbo.ls/react'
|
|
34
|
+
} else if (framework === 'vue2') {
|
|
35
|
+
pkg = '@symbo.ls/vue2'
|
|
36
|
+
} else if (framework === 'vue3') {
|
|
37
|
+
pkg = '@symbo.ls/vue3'
|
|
38
|
+
}
|
|
39
|
+
|
|
23
40
|
// TODO: inject smbls dependencies into package.json
|
|
24
41
|
|
|
25
42
|
// Install
|
|
26
|
-
console.log(
|
|
43
|
+
console.log(`Installing \`${pkg}\` from NPM...`)
|
|
27
44
|
process.chdir(dest)
|
|
28
|
-
execSync(
|
|
45
|
+
// execSync(`npm i ${pkg} --save`)
|
|
29
46
|
process.chdir(cwd)
|
|
30
47
|
|
|
31
48
|
// Copy design system file
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
console.log()
|
|
50
|
+
const dsfilePath = path.join(dest, 'DesignSystem.js')
|
|
51
|
+
console.log('Creating', chalk.bold(dsfilePath))
|
|
52
|
+
await fs.promises.copyFile(DESIGN_SYSTEM_FILE_PATH, dsfilePath)
|
|
53
|
+
|
|
54
|
+
// Copy design system file
|
|
55
|
+
const rcfilePath = path.join(dest, 'symbols.json')
|
|
56
|
+
console.log('Creating', chalk.bold(rcfilePath))
|
|
57
|
+
await fs.promises.copyFile(SYMBOLS_FILE_PATH, rcfilePath)
|
|
58
|
+
if (framework !== 'domql') addToJson(SYMBOLS_FILE_PATH, 'framework', framework)
|
|
59
|
+
console.log()
|
|
35
60
|
|
|
36
|
-
console.log('
|
|
61
|
+
console.log(chalk.green.bold('Initialized project successfully.'))
|
|
37
62
|
}
|
package/bin/init.js
CHANGED
|
@@ -7,8 +7,8 @@ program
|
|
|
7
7
|
.command('init')
|
|
8
8
|
.description('Initialize a project')
|
|
9
9
|
.argument('[dest]', 'Project directory. By default, it is "."')
|
|
10
|
-
.option('--domql', 'Use Domql in the project')
|
|
11
|
-
.option('--react', 'Use React in the project (default)'
|
|
10
|
+
.option('--domql', 'Use Domql in the project', true)
|
|
11
|
+
.option('--react', 'Use React in the project (default)')
|
|
12
12
|
.option('--angular', 'Use Angular in the project')
|
|
13
13
|
.option('--vue2', 'Use Vue2 in the project')
|
|
14
14
|
.option('--vue3', 'Use Vue3 in the project')
|
|
@@ -16,9 +16,9 @@ program
|
|
|
16
16
|
if (!dest) dest = '.'
|
|
17
17
|
|
|
18
18
|
// Determine framework
|
|
19
|
-
let framework = '
|
|
20
|
-
if (options.
|
|
21
|
-
framework = '
|
|
19
|
+
let framework = 'domql'
|
|
20
|
+
if (options.react) {
|
|
21
|
+
framework = 'react'
|
|
22
22
|
} else if (options.angular) {
|
|
23
23
|
framework = 'angular'
|
|
24
24
|
} else if (options.vue2) {
|
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
|
}
|