@symbo.ls/cli 2.11.288 → 2.11.305
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/fetch.js +36 -29
- package/bin/fs.js +97 -0
- package/bin/linking/packages.js +16 -16
- package/package.json +2 -2
package/bin/fetch.js
CHANGED
|
@@ -7,33 +7,39 @@ import { program } from './program.js'
|
|
|
7
7
|
import * as fetch from '@symbo.ls/fetch'
|
|
8
8
|
import * as utils from '@domql/utils'
|
|
9
9
|
import { convertFromCli } from './convert.js'
|
|
10
|
+
import { createDirs } from './fs.js'
|
|
10
11
|
|
|
11
12
|
const { isObjectLike } = utils.default
|
|
12
13
|
const { fetchRemote } = fetch.default
|
|
13
14
|
|
|
14
15
|
const RC_PATH = process.cwd() + '/symbols.json'
|
|
15
|
-
const LOCAL_CONFIG_PATH =
|
|
16
|
+
const LOCAL_CONFIG_PATH =
|
|
17
|
+
process.cwd() + '/node_modules/@symbo.ls/init/dynamic.json'
|
|
16
18
|
const DEFAULT_REMOTE_REPOSITORY = 'https://github.com/symbo-ls/default-config/'
|
|
17
|
-
const DEFAULT_REMOTE_CONFIG_PATH =
|
|
19
|
+
const DEFAULT_REMOTE_CONFIG_PATH = "https://api.symbols.app/"; // eslint-disable-line
|
|
18
20
|
|
|
19
|
-
const API_URL_LOCAL = 'http://localhost:13335/'
|
|
21
|
+
const API_URL_LOCAL = 'http://localhost:13335/get/'
|
|
20
22
|
const API_URL = 'https://api.symbols.app/get/'
|
|
21
23
|
|
|
22
|
-
const rcFile = loadModule(RC_PATH) // eslint-disable-line
|
|
23
|
-
const localConfig = loadModule(LOCAL_CONFIG_PATH) // eslint-disable-line
|
|
24
|
+
const rcFile = loadModule(RC_PATH); // eslint-disable-line
|
|
25
|
+
const localConfig = loadModule(LOCAL_CONFIG_PATH); // eslint-disable-line
|
|
24
26
|
|
|
25
|
-
const debugMsg = chalk.dim(
|
|
27
|
+
const debugMsg = chalk.dim(
|
|
28
|
+
'Use --verbose to debug the error or open the issue at https://github.com/symbo-ls/smbls'
|
|
29
|
+
)
|
|
26
30
|
|
|
27
31
|
let rc = {}
|
|
28
32
|
try {
|
|
29
|
-
rc = loadModule(RC_PATH) // eslint-disable-line
|
|
30
|
-
} catch (e) {
|
|
33
|
+
rc = loadModule(RC_PATH); // eslint-disable-line
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error('Please include symbols.json to your root of respository')
|
|
36
|
+
}
|
|
31
37
|
|
|
32
38
|
export const fetchFromCli = async (opts) => {
|
|
33
39
|
const { dev, verbose, prettify, convert: convertOpt } = opts
|
|
34
40
|
|
|
35
|
-
await rc.then(async data => {
|
|
36
|
-
const { key, framework } = data
|
|
41
|
+
await rc.then(async (data) => {
|
|
42
|
+
const { key, framework, distDir } = data
|
|
37
43
|
|
|
38
44
|
const endpoint = dev ? API_URL_LOCAL : API_URL
|
|
39
45
|
|
|
@@ -54,7 +60,11 @@ export const fetchFromCli = async (opts) => {
|
|
|
54
60
|
|
|
55
61
|
if (verbose) {
|
|
56
62
|
if (key) {
|
|
57
|
-
console.log(
|
|
63
|
+
console.log(
|
|
64
|
+
chalk.bold('Symbols'),
|
|
65
|
+
'data fetched for',
|
|
66
|
+
chalk.green(body.name)
|
|
67
|
+
)
|
|
58
68
|
} else {
|
|
59
69
|
console.log(
|
|
60
70
|
chalk.bold('Symbols'),
|
|
@@ -85,33 +95,30 @@ export const fetchFromCli = async (opts) => {
|
|
|
85
95
|
delete body.designsystem
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
const
|
|
89
|
-
if (!monetized) {
|
|
90
|
-
const bodyString = JSON.stringify(body, null, prettify ?? 2)
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
await fs.writeFileSync(LOCAL_CONFIG_PATH, bodyString)
|
|
98
|
+
const bodyString = JSON.stringify(body, null, prettify ?? 2)
|
|
94
99
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
console.log(chalk.dim.underline(LOCAL_CONFIG_PATH))
|
|
98
|
-
}
|
|
100
|
+
try {
|
|
101
|
+
await fs.writeFileSync(LOCAL_CONFIG_PATH, bodyString)
|
|
99
102
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
console.log(chalk.
|
|
103
|
-
if (verbose) console.error(e)
|
|
104
|
-
else console.log(debugMsg)
|
|
103
|
+
if (verbose) {
|
|
104
|
+
console.log(chalk.dim('\ndynamic.json has been updated:'))
|
|
105
|
+
console.log(chalk.dim.underline(LOCAL_CONFIG_PATH))
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
|
|
108
|
+
console.log(chalk.bold.green('\nSuccessfully wrote file'))
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.log(chalk.bold.red('\nError writing file'))
|
|
111
|
+
if (verbose) console.error(e)
|
|
112
|
+
else console.log(debugMsg)
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
console.log(convertOpt)
|
|
112
116
|
if (body.components && convertOpt && framework) {
|
|
113
117
|
convertFromCli(body.components, { ...opts, framework })
|
|
114
118
|
}
|
|
119
|
+
|
|
120
|
+
console.log(Object.keys(body))
|
|
121
|
+
createDirs(body, distDir)
|
|
115
122
|
})
|
|
116
123
|
}
|
|
117
124
|
|
package/bin/fs.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import utils from '@domql/utils'
|
|
6
|
+
const { deepDestringify, objectToString, joinArrays } = utils
|
|
7
|
+
|
|
8
|
+
const keys = ['components', 'snippets', 'pages']
|
|
9
|
+
const singleFileKeys = ['designSystem', 'state']
|
|
10
|
+
|
|
11
|
+
export function createDirs (body, distDir) {
|
|
12
|
+
if (!body) {
|
|
13
|
+
console.error('No JSON object provided. Exiting.')
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
distDir = distDir || path.join(process.cwd(), 'dist')
|
|
18
|
+
|
|
19
|
+
keys.forEach((key) => {
|
|
20
|
+
createKeyDirectoryAndFiles(key, body, distDir)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
singleFileKeys.forEach((key) => {
|
|
24
|
+
if (body[key] && typeof body[key] === 'object') {
|
|
25
|
+
createSingleFileFolderAndFile(key, body[key], distDir)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
generateRootIndexjsFile(joinArrays(keys, singleFileKeys), distDir)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function generateIndexjsFile (dirs, dirPath) {
|
|
33
|
+
const indexContent = dirs.map(d => `export * from './${d}'`).join('\n') + '\n'
|
|
34
|
+
const indexFilePath = path.join(dirPath, 'index.js')
|
|
35
|
+
const fh = await fs.promises.open(indexFilePath, 'w')
|
|
36
|
+
await fh.writeFile(indexContent, 'utf8')
|
|
37
|
+
await fh.close()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function generateRootIndexjsFile (dirs, dirPath) {
|
|
41
|
+
const indexContent = dirs.map(d => {
|
|
42
|
+
const isSingleFile = singleFileKeys.includes(d)
|
|
43
|
+
if (isSingleFile) return `export { default as ${d} } from './${d}'`
|
|
44
|
+
return `export * as ${d} from './${d}'`
|
|
45
|
+
}).join('\n') + '\n'
|
|
46
|
+
const indexFilePath = path.join(dirPath, 'index.js')
|
|
47
|
+
const fh = await fs.promises.open(indexFilePath, 'w')
|
|
48
|
+
await fh.writeFile(indexContent, 'utf8')
|
|
49
|
+
await fh.close()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function createKeyDirectoryAndFiles (key, body, distDir) {
|
|
53
|
+
const dirPath = path.join(distDir, key)
|
|
54
|
+
fs.existsSync(dirPath) || fs.mkdirSync(dirPath, { recursive: true })
|
|
55
|
+
console.log(
|
|
56
|
+
`${fs.existsSync(dirPath) ? 'Found' : 'Created'} directory: ${dirPath}`
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
const dirs = []
|
|
60
|
+
if (body[key] && typeof body[key] === 'object') {
|
|
61
|
+
Object.entries(body[key]).forEach(([entryKey, value]) => {
|
|
62
|
+
let childKey = entryKey
|
|
63
|
+
if (childKey.startsWith('/')) {
|
|
64
|
+
childKey = childKey.slice(1)
|
|
65
|
+
if (!childKey.length) childKey = 'main'
|
|
66
|
+
}
|
|
67
|
+
createOrUpdateFile(dirPath, childKey, value)
|
|
68
|
+
dirs.push(childKey)
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
generateIndexjsFile(dirs, dirPath, key)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function createOrUpdateFile (dirPath, childKey, value) {
|
|
76
|
+
const filePath = path.join(dirPath, `${childKey}.js`)
|
|
77
|
+
|
|
78
|
+
const content = deepDestringify(value)
|
|
79
|
+
const stringifiedContent = `export const ${childKey} = ${objectToString(content)}`
|
|
80
|
+
|
|
81
|
+
const fileExists = fs.existsSync(filePath)
|
|
82
|
+
|
|
83
|
+
console.log(`${fileExists ? 'Updating' : 'Creating new'} file: ${filePath}`);
|
|
84
|
+
(fileExists && fs.readFileSync(filePath, 'utf8') === content) ||
|
|
85
|
+
fs.writeFileSync(filePath, stringifiedContent)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function createSingleFileFolderAndFile (key, data, distDir) {
|
|
89
|
+
const filePath = path.join(distDir, `${key}.js`)
|
|
90
|
+
const content = deepDestringify(data)
|
|
91
|
+
const stringifiedContent = `export default ${objectToString(content)}`
|
|
92
|
+
const fileExists = fs.existsSync(filePath)
|
|
93
|
+
|
|
94
|
+
console.log(`${fileExists ? 'Updating' : 'Creating new'} file: ${filePath}`);
|
|
95
|
+
(fileExists && fs.readFileSync(filePath, 'utf8') === content) ||
|
|
96
|
+
fs.writeFileSync(filePath, stringifiedContent)
|
|
97
|
+
}
|
package/bin/linking/packages.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export default [
|
|
2
|
+
'@symbo.ls/create',
|
|
3
|
+
'@symbo.ls/convert',
|
|
2
4
|
'attrs-in-props',
|
|
3
5
|
'@symbo.ls/cli',
|
|
4
|
-
'@symbo.ls/convert',
|
|
5
|
-
'@symbo.ls/create',
|
|
6
|
-
'@symbo.ls/default-config',
|
|
7
6
|
'css-in-props',
|
|
8
|
-
'@symbo.ls/
|
|
7
|
+
'@symbo.ls/default-config',
|
|
9
8
|
'@symbo.ls/emotion',
|
|
9
|
+
'@symbo.ls/fetch',
|
|
10
10
|
'@symbo.ls/init',
|
|
11
11
|
'@symbo.ls/preview',
|
|
12
12
|
'@symbo.ls/scratch',
|
|
@@ -17,12 +17,12 @@ export default [
|
|
|
17
17
|
'@symbo.ls/utils',
|
|
18
18
|
'@symbo.ls/default-icons',
|
|
19
19
|
'@symbo.ls/feather-icons',
|
|
20
|
-
'@symbo.ls/material-icons',
|
|
21
20
|
'@symbo.ls/fluent-icons',
|
|
21
|
+
'@symbo.ls/material-icons',
|
|
22
22
|
'@symbo.ls/editorjs',
|
|
23
23
|
'@symbo.ls/google-maps',
|
|
24
|
-
'@symbo.ls/markdown',
|
|
25
24
|
'@symbo.ls/helmet',
|
|
25
|
+
'@symbo.ls/markdown',
|
|
26
26
|
'@symbo.ls/atoms',
|
|
27
27
|
'@symbo.ls/avatar',
|
|
28
28
|
'@symbo.ls/banner',
|
|
@@ -31,35 +31,35 @@ export default [
|
|
|
31
31
|
'@symbo.ls/card',
|
|
32
32
|
'@symbo.ls/datepicker',
|
|
33
33
|
'@symbo.ls/dialog',
|
|
34
|
-
'@symbo.ls/dropdown',
|
|
35
34
|
'@symbo.ls/doublehr',
|
|
35
|
+
'@symbo.ls/dropdown',
|
|
36
36
|
'@symbo.ls/field',
|
|
37
37
|
'@symbo.ls/form',
|
|
38
38
|
'@symbo.ls/hgroup',
|
|
39
39
|
'@symbo.ls/icon',
|
|
40
|
-
'@symbo.ls/input',
|
|
41
|
-
'@symbo.ls/label',
|
|
42
40
|
'@symbo.ls/indicator',
|
|
41
|
+
'@symbo.ls/input',
|
|
43
42
|
'@symbo.ls/link',
|
|
43
|
+
'@symbo.ls/label',
|
|
44
44
|
'@symbo.ls/list',
|
|
45
45
|
'@symbo.ls/modal',
|
|
46
|
-
'@symbo.ls/notification',
|
|
47
46
|
'@symbo.ls/paragraphbutton',
|
|
48
|
-
'@symbo.ls/
|
|
47
|
+
'@symbo.ls/notification',
|
|
49
48
|
'@symbo.ls/progress',
|
|
50
|
-
'@symbo.ls/
|
|
49
|
+
'@symbo.ls/pills',
|
|
51
50
|
'@symbo.ls/range',
|
|
51
|
+
'@symbo.ls/select',
|
|
52
52
|
'@symbo.ls/sidebar',
|
|
53
53
|
'@symbo.ls/slider',
|
|
54
|
-
'@symbo.ls/
|
|
54
|
+
'@symbo.ls/sociallink',
|
|
55
55
|
'@symbo.ls/tab',
|
|
56
|
+
'@symbo.ls/steps',
|
|
56
57
|
'@symbo.ls/table',
|
|
57
|
-
'@symbo.ls/sociallink',
|
|
58
58
|
'@symbo.ls/threejs',
|
|
59
|
-
'@symbo.ls/timepicker',
|
|
60
59
|
'@symbo.ls/tooltip',
|
|
61
|
-
'@symbo.ls/
|
|
60
|
+
'@symbo.ls/timepicker',
|
|
62
61
|
'@symbo.ls/upload',
|
|
62
|
+
'@symbo.ls/unitvalue',
|
|
63
63
|
'@symbo.ls/user',
|
|
64
64
|
'@symbo.ls/video'
|
|
65
65
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/cli",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.305",
|
|
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
|
"@symbo.ls/convert": "latest"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "14569e713ad6d47a3be207df9f23dc0338a2d562"
|
|
31
31
|
}
|