@symbo.ls/cli 3.1.2 → 3.2.3

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/create.js CHANGED
@@ -35,8 +35,14 @@ program
35
35
  .option('--angular', 'Use Angular in the project')
36
36
  .option('--vue2', 'Use Vue2 in the project')
37
37
  .option('--vue3', 'Use Vue3 in the project')
38
- .option('--package-manager <manager>', 'Choose the package manager (e.g., npm, yarn)', 'npm')
38
+ .option(
39
+ '--package-manager <manager>',
40
+ 'Choose the package manager (e.g., npm, yarn)',
41
+ 'npm'
42
+ )
39
43
  .option('--clean-from-git', 'remove starter-kit git repository', true)
44
+ .option('--no-dependencies', 'Skip installing dependencies')
45
+ .option('--no-clone', 'Create folder instead of cloning from git')
40
46
  .action(async (dest = 'symbols-starter-kit', options) => {
41
47
  // Determine framework
42
48
  let framework = 'domql'
@@ -57,39 +63,79 @@ program
57
63
  return
58
64
  }
59
65
 
60
- console.log(`Cloning ${cloneUrl} into '${dest}'...`)
61
- execSync(`git clone ${options.remote ? ' -b feature/remote' : ''} ${cloneUrl} ${dest}`)
66
+ if (options.clone) {
67
+ console.log(`Cloning ${cloneUrl} into '${dest}'...`)
68
+ execSync(
69
+ `git clone ${
70
+ options.remote ? ' -b feature/remote' : ''
71
+ } ${cloneUrl} ${dest}`
72
+ )
73
+ } else {
74
+ console.log(`Creating directory '${dest}'...`)
75
+ fs.mkdirSync(dest, { recursive: true })
76
+ }
62
77
 
63
78
  process.chdir(dest)
64
79
 
65
80
  const SYMBOLS_FILE_PATH = path.join(process.cwd(), 'symbols.json')
66
- addToJson(SYMBOLS_FILE_PATH, 'key', `${dest}.symbo.ls`)
67
- addToJson(SYMBOLS_FILE_PATH, 'packageManager', `${packageManager}`)
68
-
69
- console.log(`Installing dependencies using ${packageManager}...`)
70
-
71
- const exc = exec(packageManager === 'yarn' ? 'yarn' : 'npm i')
72
81
 
73
- if (options.verbose) {
74
- exc.stdout.on('data', (data) => {
75
- console.log(data)
76
- })
77
- exc.stderr.on('data', (data) => {
78
- console.error(data)
79
- })
82
+ // Create symbols.json if not using clone
83
+ if (!options.clone) {
84
+ const initialSymbolsJson = {
85
+ key: `${dest}.symbo.ls`,
86
+ packageManager: packageManager
87
+ }
88
+ fs.writeFileSync(
89
+ SYMBOLS_FILE_PATH,
90
+ JSON.stringify(initialSymbolsJson, null, 2)
91
+ )
92
+ console.log('Created symbols.json file')
80
93
  } else {
81
- console.log(chalk.dim('Use --verbose to print the output'))
94
+ addToJson(SYMBOLS_FILE_PATH, 'key', `${dest}.symbo.ls`)
95
+ addToJson(SYMBOLS_FILE_PATH, 'packageManager', `${packageManager}`)
82
96
  }
83
97
 
84
- console.log()
98
+ if (options.dependencies) {
99
+ console.log(`Installing dependencies using ${packageManager}...`)
100
+
101
+ const exc = exec(packageManager === 'yarn' ? 'yarn' : 'npm i')
85
102
 
86
- exc.on('close', (code) => {
103
+ if (options.verbose) {
104
+ exc.stdout.on('data', data => {
105
+ console.log(data)
106
+ })
107
+ exc.stderr.on('data', data => {
108
+ console.error(data)
109
+ })
110
+ } else {
111
+ console.log(chalk.dim('Use --verbose to print the output'))
112
+ }
113
+
114
+ console.log()
115
+
116
+ exc.on('close', code => {
117
+ console.log()
118
+ console.log(chalk.green.bold(dest), 'successfuly created!')
119
+ console.log(
120
+ `Done! run \`${chalk.bold(
121
+ 'cd ' + dest + '; ' + packageManager + ' start'
122
+ )}\` to start the development server.`
123
+ )
124
+ })
125
+ } else {
126
+ console.log(
127
+ chalk.dim('Skipping dependency installation (--no-dependencies)')
128
+ )
87
129
  console.log()
88
130
  console.log(chalk.green.bold(dest), 'successfuly created!')
89
- console.log(`Done! run \`${chalk.bold('cd ' + dest + '; ' + packageManager + ' start')}\` to start the development server.`)
90
- })
131
+ console.log(
132
+ `Done! Now run \`${chalk.bold(
133
+ 'cd ' + dest
134
+ )}\` and install dependencies manually.`
135
+ )
136
+ }
91
137
 
92
- if (options.cleanFromGit) {
138
+ if (options.cleanFromGit && options.clone) {
93
139
  fs.rmSync('.git', {
94
140
  recursive: true,
95
141
  force: true
package/bin/fetch.js CHANGED
@@ -8,20 +8,20 @@ import * as fetch from '@symbo.ls/fetch'
8
8
  import * as utils from '@domql/utils'
9
9
  import { convertFromCli } from './convert.js'
10
10
  import { createFs } from './fs.js'
11
- const { isObjectLike } = (utils.default || utils)
12
- const { fetchRemote } = (fetch.default || fetch)
11
+ const { isObjectLike } = utils.default || utils
12
+ const { fetchRemote } = fetch.default || fetch
13
13
 
14
14
  const RC_PATH = process.cwd() + '/symbols.json'
15
15
  const LOCAL_CONFIG_PATH =
16
16
  process.cwd() + '/node_modules/@symbo.ls/init/dynamic.json'
17
17
  const DEFAULT_REMOTE_REPOSITORY = 'https://github.com/symbo-ls/default-config/'
18
- const DEFAULT_REMOTE_CONFIG_PATH = "https://api.symbols.app/"; // eslint-disable-line
18
+ const DEFAULT_REMOTE_CONFIG_PATH = 'https://api.symbols.app/' // eslint-disable-line
19
19
 
20
- const API_URL_LOCAL = 'http://localhost:13335/get'
20
+ const API_URL_LOCAL = 'http://localhost:8080/get'
21
21
  const API_URL = 'https://api.symbols.app/get'
22
22
 
23
- const rcFile = loadModule(RC_PATH); // eslint-disable-line
24
- const localConfig = loadModule(LOCAL_CONFIG_PATH); // eslint-disable-line
23
+ const rcFile = loadModule(RC_PATH) // eslint-disable-line
24
+ const localConfig = loadModule(LOCAL_CONFIG_PATH) // eslint-disable-line
25
25
 
26
26
  const debugMsg = chalk.dim(
27
27
  'Use --verbose to debug the error or open the issue at https://github.com/symbo-ls/smbls'
@@ -29,24 +29,32 @@ const debugMsg = chalk.dim(
29
29
 
30
30
  let rc = {}
31
31
  try {
32
- rc = loadModule(RC_PATH); // eslint-disable-line
32
+ rc = loadModule(RC_PATH) // eslint-disable-line
33
33
  } catch (e) {
34
34
  console.error('Please include symbols.json to your root of respository')
35
35
  }
36
36
 
37
- export const fetchFromCli = async (opts) => {
38
- const { dev, verbose, prettify, convert: convertOpt, metadata: metadataOpt, update, force } = opts
39
- await rc.then(async (data) => {
40
- const { key, framework, distDir, metadata } = data
41
-
42
- const endpoint = dev ? API_URL_LOCAL : API_URL
37
+ export const fetchFromCli = async opts => {
38
+ const {
39
+ dev,
40
+ verbose,
41
+ prettify,
42
+ convert: convertOpt,
43
+ metadata: metadataOpt,
44
+ update,
45
+ force
46
+ } = opts
47
+ await rc.then(async data => {
48
+ const { key, framework, distDir, metadata } = data || {}
49
+
50
+ const endpoint = dev || utils.isLocal() ? API_URL_LOCAL : API_URL
43
51
 
44
52
  console.log('\nFetching from:', chalk.bold(endpoint), '\n')
45
53
 
46
54
  const body = await fetchRemote(key, {
47
55
  endpoint,
48
56
  metadata: metadata || metadataOpt,
49
- onError: (e) => {
57
+ onError: e => {
50
58
  console.log(chalk.red('Failed to fetch:'), key)
51
59
  if (verbose) console.error(e)
52
60
  else console.log(debugMsg)
@@ -111,7 +119,9 @@ export const fetchFromCli = async (opts) => {
111
119
  }
112
120
 
113
121
  console.log()
114
- console.warn('No --dist-dir option or "distDir" in symbols.json provided. Saving in ./node_modules/@symbo.ls/init/dynamic.json.')
122
+ console.warn(
123
+ 'No --dist-dir option or "distDir" in symbols.json provided. Saving in ./node_modules/@symbo.ls/init/dynamic.json.'
124
+ )
115
125
  return {}
116
126
  }
117
127
 
package/bin/sync.js CHANGED
@@ -10,30 +10,37 @@ import * as socketClient from '@symbo.ls/socket/client.js'
10
10
  import { fetchFromCli } from './fetch.js'
11
11
  import { convertFromCli } from './convert.js'
12
12
 
13
- const { debounce } = (utils.default || utils)
13
+ const { debounce } = utils.default || utils
14
14
 
15
- const SOCKET_API_URL_LOCAL = 'http://localhost:13336/'
16
- const SOCKET_API_URL = 'https://socket.symbols.app/'
15
+ const SOCKET_API_URL_LOCAL = 'http://localhost:8080/'
16
+ const SOCKET_API_URL = 'https://api.symbols.app/'
17
17
 
18
- const debugMsg = chalk.dim('Use --verbose to debug the error or open the issue at https://github.com/symbo-ls/smbls')
18
+ const debugMsg = chalk.dim(
19
+ 'Use --verbose to debug the error or open the issue at https://github.com/symbo-ls/smbls'
20
+ )
19
21
 
20
22
  const RC_PATH = process.cwd() + '/symbols.json'
21
23
  let rc = {}
22
24
  try {
23
25
  rc = loadModule(RC_PATH) // eslint-disable-line
24
- } catch (e) { console.error('Please include symbols.json to your root of respository') }
26
+ } catch (e) {
27
+ console.error('Please include symbols.json to your root of respository')
28
+ }
25
29
 
26
30
  program
27
31
  .command('sync')
28
32
  .description('Realtime sync with Symbols')
29
33
  .option('-d, --dev', 'Running from local server')
30
34
  .option('-v, --verbose', 'Verbose errors and warnings')
31
- .option('-k, --key', 'Bypass the symbols.json key, overriding the key manually')
35
+ .option(
36
+ '-k, --key',
37
+ 'Bypass the symbols.json key, overriding the key manually'
38
+ )
32
39
  .option('-f, --fetch', 'Verbose errors and warnings', true)
33
40
  .option('--convert', 'Verbose errors and warnings', true)
34
41
  .option('--update', 'overriding changes from platform', true)
35
42
  .option('--verbose-code', 'Verbose errors and warnings')
36
- .action(async (opts) => {
43
+ .action(async opts => {
37
44
  const { dev, verbose, fetch: fetchOpt, convert: convertOpt } = opts
38
45
 
39
46
  if (fetchOpt) {
@@ -61,7 +68,13 @@ program
61
68
  source: 'cli',
62
69
  socketUrl,
63
70
  onConnect: (id, socket) => {
64
- console.log('Connected to', chalk.green(key), 'from', chalk.bold('Symbols'), 'socket server')
71
+ console.log(
72
+ 'Connected to',
73
+ chalk.green(key),
74
+ 'from',
75
+ chalk.bold('Symbols'),
76
+ 'socket server'
77
+ )
65
78
  console.log('Socket id:', id)
66
79
  console.log(chalk.dim('\nListening to updates...\n'))
67
80
  },
@@ -83,7 +96,8 @@ program
83
96
  console.log(chalk.dim('\n----------------\n'))
84
97
  console.log(chalk.dim('Received update:'))
85
98
  console.log(Object.keys(d).join(', '))
86
- if (verboseCode) console.log(chalk.dim(JSON.stringify(d, null, prettify ?? 2)))
99
+ if (verboseCode)
100
+ console.log(chalk.dim(JSON.stringify(d, null, prettify ?? 2)))
87
101
 
88
102
  if (distDir) {
89
103
  if (fetchOpt) {
@@ -98,7 +112,8 @@ program
98
112
 
99
113
  if (d.components && convertOpt && framework) {
100
114
  convertFromCli(d.components, {
101
- ...options, framework
115
+ ...options,
116
+ framework
102
117
  })
103
118
  }
104
119
  }, 1500),
package/helpers/config.js CHANGED
@@ -22,6 +22,6 @@ export const getApiUrl = () => {
22
22
  case 'staging':
23
23
  return 'https://api-staging.symbols.app'
24
24
  default:
25
- return 'http://localhost:13335'
25
+ return 'http://localhost:8080'
26
26
  }
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "3.1.2",
3
+ "version": "3.2.3",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "bin/fetch.js",
6
6
  "author": "Symbols",
@@ -15,9 +15,9 @@
15
15
  "vpatch": "npm version patch && npm publish"
16
16
  },
17
17
  "dependencies": {
18
- "@symbo.ls/fetch": "^3.1.2",
19
- "@symbo.ls/init": "^3.1.2",
20
- "@symbo.ls/socket": "^3.1.2",
18
+ "@symbo.ls/fetch": "^3.2.3",
19
+ "@symbo.ls/init": "^3.2.3",
20
+ "@symbo.ls/socket": "^3.2.3",
21
21
  "chalk": "^5.4.1",
22
22
  "commander": "^13.1.0",
23
23
  "diff": "^5.2.0",
@@ -26,5 +26,5 @@
26
26
  "node-fetch": "^3.3.2",
27
27
  "v8-compile-cache": "^2.4.0"
28
28
  },
29
- "gitHead": "429b36616aa04c8587a26ce3c129815115e35897"
29
+ "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681"
30
30
  }