@symbo.ls/cli 0.6.26 → 0.6.27
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/clean.js +11 -0
- package/bin/fetch.js +34 -23
- package/bin/index.js +6 -0
- package/bin/init.js +1 -3
- package/bin/program.js +4 -0
- package/bin/require.js +4 -6
- package/bin/sync.js +9 -1
- package/package.json +2 -2
package/bin/clean.js
ADDED
package/bin/fetch.js
CHANGED
|
@@ -4,28 +4,47 @@ import fs from 'fs'
|
|
|
4
4
|
import fetch from 'node-fetch'
|
|
5
5
|
import chalk from 'chalk'
|
|
6
6
|
import { loadModule } from './require.js'
|
|
7
|
-
import { Command } from 'commander'
|
|
8
7
|
import { exec } from 'child_process'
|
|
8
|
+
import { program } from './program.js'
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const PACKAGE_PATH = process.cwd() + '/package.json'
|
|
11
|
+
const RC_PATH = process.cwd() + '/node_modules/@symbo.ls/init/src/dynamic.json'
|
|
12
|
+
const LOCAL_CONFIG_PATH = process.cwd() + '/node_modules/@symbo.ls/init/src/dynamic.json'
|
|
13
|
+
const DEFAULT_REMOTE_REPOSITORY = 'https://github.com/symbo-ls/config-default/'
|
|
14
|
+
const DEFAULT_REMOTE_CONFIG_PATH = 'https://raw.githubusercontent.com/symbo-ls/config-default/main/src/config.json'
|
|
12
15
|
|
|
13
16
|
const API_URL = 'https://api.symbols.app/' // eslint-disable-line
|
|
14
|
-
|
|
15
|
-
const
|
|
17
|
+
|
|
18
|
+
const pkg = loadModule(PACKAGE_PATH)
|
|
19
|
+
const rc_file = loadModule(RC_PATH)
|
|
20
|
+
const local_config = loadModule(LOCAL_CONFIG_PATH)
|
|
16
21
|
|
|
17
22
|
program
|
|
18
23
|
.version(pkg.version)
|
|
19
24
|
|
|
20
25
|
program
|
|
21
|
-
.command('
|
|
22
|
-
.description('
|
|
23
|
-
.option('
|
|
24
|
-
.action(async (
|
|
25
|
-
const packageName = `@symbo.ls/${mode || 'uikit'}`
|
|
26
|
+
.command('install')
|
|
27
|
+
.description('Install Symbols')
|
|
28
|
+
.option('--framework', 'Which Symbols to install (domql, react)')
|
|
29
|
+
.action(async (framework) => {
|
|
30
|
+
// const packageName = `@symbo.ls/${mode || 'uikit'}`
|
|
31
|
+
const packageName = `smbls`
|
|
26
32
|
console.log('Adding', chalk.green.bold(packageName))
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
if (framework === 'domql' || rc_file.framework === 'domql') {
|
|
35
|
+
exec(`yarn add domql@^1.15.26 --force`, (error, stdout, stderr) => {
|
|
36
|
+
if (error) {
|
|
37
|
+
console.log(`error: ${error.message}`)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (stderr) {
|
|
41
|
+
console.log(`stderr: ${stderr}`)
|
|
42
|
+
// return;
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exec(`yarn add ${packageName}@^0.15.22 --force`, (error, stdout, stderr) => {
|
|
29
48
|
if (error) {
|
|
30
49
|
console.log(`error: ${error.message}`)
|
|
31
50
|
return
|
|
@@ -46,27 +65,22 @@ program
|
|
|
46
65
|
.command('fetch [destination]')
|
|
47
66
|
.description('Fetch symbols')
|
|
48
67
|
.action(async (source, destination) => {
|
|
49
|
-
const response = await fetch(
|
|
68
|
+
const response = await fetch(DEFAULT_REMOTE_CONFIG_PATH)
|
|
50
69
|
const body = await response.json()
|
|
51
70
|
const { version, ...config } = body
|
|
52
71
|
|
|
53
|
-
console.log(
|
|
54
|
-
|
|
72
|
+
console.log(chalk.dim('- Default config from:'), chalk.dim.underline(DEFAULT_REMOTE_REPOSITORY))
|
|
55
73
|
console.log('')
|
|
56
74
|
console.log(chalk.bold('Symbols'), 'config fetched:', chalk.green(version))
|
|
57
|
-
console.log(chalk.dim('- Default config from:'), chalk.dim.underline(LOG_DEST))
|
|
58
75
|
|
|
59
|
-
|
|
60
|
-
console.log(chalk.dim('- .symbolsrc.json created:'), chalk.dim.underline(path))
|
|
76
|
+
console.log(chalk.dim('- .symbolsrc.json created:'), chalk.dim.underline(LOCAL_CONFIG_PATH))
|
|
61
77
|
console.log('')
|
|
62
78
|
|
|
63
79
|
const bodyString = JSON.stringify(body)
|
|
64
|
-
fs.writeFile(
|
|
80
|
+
fs.writeFile(LOCAL_CONFIG_PATH, bodyString, err => {
|
|
65
81
|
if (err) {
|
|
66
82
|
console.log('Error writing file', err)
|
|
67
83
|
} else {
|
|
68
|
-
const initPath = process.cwd() + '/node_modules/@symbo.ls/scratch-init/.symbolsrc.json'
|
|
69
|
-
fs.writeFile(initPath, bodyString, err => { if (err) throw err })
|
|
70
84
|
console.log('Successfully wrote file')
|
|
71
85
|
}
|
|
72
86
|
})
|
|
@@ -78,6 +92,3 @@ program
|
|
|
78
92
|
console.log(Object.keys(type))
|
|
79
93
|
}
|
|
80
94
|
})
|
|
81
|
-
|
|
82
|
-
const args = process.argv
|
|
83
|
-
program.parse(args)
|
package/bin/index.js
CHANGED
package/bin/init.js
CHANGED
package/bin/program.js
ADDED
package/bin/require.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
class ImportError extends Error {}
|
|
2
2
|
|
|
3
|
+
import { createRequire } from "module"; // Bring in the ability to create the 'require' method
|
|
4
|
+
const require = createRequire(import.meta.url); // construct the require method
|
|
5
|
+
|
|
3
6
|
export const loadModule = async (modulePath) => {
|
|
4
|
-
|
|
5
|
-
return await import(modulePath)
|
|
6
|
-
} catch (e) {
|
|
7
|
-
console.warn('Cant found', modulePath)
|
|
8
|
-
// throw new ImportError(`Unable to import module ${modulePath}`)
|
|
9
|
-
}
|
|
7
|
+
return require(modulePath) // use the require method
|
|
10
8
|
}
|
package/bin/sync.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.27",
|
|
4
4
|
"description": "Fetch your Symbols configuration",
|
|
5
5
|
"main": "bin/fetch.js",
|
|
6
6
|
"author": "Symbols",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"vpatch": "npm version patch && npm publish"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@symbo.ls/socket": "latest",
|
|
20
19
|
"@symbo.ls/init": "latest",
|
|
20
|
+
"@symbo.ls/socket": "latest",
|
|
21
21
|
"chalk": "^5.0.0",
|
|
22
22
|
"commander": "^8.3.0",
|
|
23
23
|
"node-fetch": "^3.1.0",
|