@symbo.ls/cli 2.11.365 → 2.11.369

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.
Files changed (3) hide show
  1. package/bin/fetch.js +10 -7
  2. package/bin/fs.js +17 -7
  3. package/package.json +2 -2
package/bin/fetch.js CHANGED
@@ -18,8 +18,8 @@ const LOCAL_CONFIG_PATH =
18
18
  const DEFAULT_REMOTE_REPOSITORY = 'https://github.com/symbo-ls/default-config/'
19
19
  const DEFAULT_REMOTE_CONFIG_PATH = "https://api.symbols.app/"; // eslint-disable-line
20
20
 
21
- const API_URL_LOCAL = 'http://localhost:13335/get/'
22
- const API_URL = 'https://api.symbols.app/get/'
21
+ const API_URL_LOCAL = 'http://localhost:13335/get'
22
+ const API_URL = 'https://api.symbols.app/get'
23
23
 
24
24
  const rcFile = loadModule(RC_PATH); // eslint-disable-line
25
25
  const localConfig = loadModule(LOCAL_CONFIG_PATH); // eslint-disable-line
@@ -36,16 +36,19 @@ try {
36
36
  }
37
37
 
38
38
  export const fetchFromCli = async (opts) => {
39
- const { dev, verbose, prettify, convert: convertOpt, update } = opts
39
+ const { dev, verbose, prettify, convert: convertOpt, metadata: metadataOpt, update } = opts
40
40
  await rc.then(async (data) => {
41
- const { key, framework, distDir } = data
41
+ const { key, framework, distDir, metadata } = data
42
42
 
43
43
  const endpoint = dev ? API_URL_LOCAL : API_URL
44
44
 
45
45
  console.log('\nFetching from:', chalk.bold(endpoint), '\n')
46
46
 
47
+ console.log('metadata')
48
+ console.log(metadata, metadataOpt)
47
49
  const body = await fetchRemote(key, {
48
50
  endpoint,
51
+ metadata: metadata || metadataOpt,
49
52
  onError: (e) => {
50
53
  console.log(chalk.red('Failed to fetch:'), key)
51
54
  if (verbose) console.error(e)
@@ -111,15 +114,14 @@ export const fetchFromCli = async (opts) => {
111
114
  else console.log(debugMsg)
112
115
  }
113
116
 
114
- console.log(convertOpt)
115
117
  if (body.components && convertOpt && framework) {
116
118
  convertFromCli(body.components, { ...opts, framework })
117
119
  }
118
120
 
119
121
  if (update) {
120
- createFs(body, distDir, update)
122
+ createFs(body, distDir, { update: true, metadata })
121
123
  } else {
122
- createFs(body, distDir)
124
+ createFs(body, distDir, { metadata })
123
125
  }
124
126
  })
125
127
  }
@@ -130,6 +132,7 @@ program
130
132
  .option('-d, --dev', 'Running from local server')
131
133
  .option('-v, --verbose', 'Verbose errors and warnings')
132
134
  .option('--convert', 'Verbose errors and warnings', true)
135
+ .option('--metadata', 'Include metadata', false)
133
136
  .option('--update', 'overriding changes from platform')
134
137
  .option('--verbose-code', 'Verbose errors and warnings')
135
138
  .action(fetchFromCli)
package/bin/fs.js CHANGED
@@ -5,27 +5,35 @@ import utils from '@domql/utils'
5
5
  import * as smblsUtils from '@symbo.ls/utils'
6
6
  import inquirer from 'inquirer'
7
7
  import { createPatch } from 'diff'
8
+ import { fileURLToPath } from 'url'
9
+
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
11
 
9
12
  const { removeChars, toCamelCase } = smblsUtils.default
10
- const { deepDestringify, objectToString, joinArrays, isString } = utils
13
+ const { deepDestringify, objectToString, joinArrays, isString, removeValueFromArray } = utils
11
14
 
12
- const LOCAL_CONFIG_PATH =
13
- process.cwd() + '/node_modules/@symbo.ls/init/dynamic.json'
15
+ const LOCAL_CONFIG_PATH = path.resolve(__dirname, '/node_modules/@symbo.ls/init/dynamic.json')
16
+ const LOCAL_CONFIG_PATH2 = process.cwd() + '/symbols.json'
14
17
 
18
+ let singleFileKeys = ['designSystem', 'state']
15
19
  const keys = ['components', 'snippets', 'pages']
16
- const singleFileKeys = ['designSystem', 'state']
17
- const defaultExports = ['pages', 'designSystem', 'state']
20
+ const defaultExports = ['pages', 'designSystem', 'state', 'schema']
18
21
 
19
22
  export async function createFs (
20
23
  body,
21
- distDir = path.join(process.cwd(), 'dist'),
22
- update = false
24
+ distDir = path.join(process.cwd(), 'smbls'),
25
+ opts = {}
23
26
  ) {
24
27
  if (!body) {
25
28
  console.error('No JSON object provided. Exiting.')
26
29
  return
27
30
  }
28
31
 
32
+ const { update, metadata } = opts
33
+
34
+ singleFileKeys = removeValueFromArray(singleFileKeys, 'schema')
35
+ if (metadata) singleFileKeys.push('schema')
36
+
29
37
  const targetDir = distDir
30
38
 
31
39
  const filesExist = fs.existsSync(targetDir)
@@ -177,6 +185,8 @@ export async function createFs (
177
185
  // fs.writeFileSync(destPath, genStr)
178
186
  // }
179
187
 
188
+ console.log(LOCAL_CONFIG_PATH)
189
+ console.log(LOCAL_CONFIG_PATH2)
180
190
  await fs.writeFileSync(LOCAL_CONFIG_PATH, '{}')
181
191
  }
182
192
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.11.365",
3
+ "version": "2.11.369",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "bin/fetch.js",
6
6
  "author": "Symbols",
@@ -26,5 +26,5 @@
26
26
  "node-fetch": "^3.1.0",
27
27
  "v8-compile-cache": "^2.3.0"
28
28
  },
29
- "gitHead": "27ab0a87d9a8ccf8eb50512b96b3015e15610910"
29
+ "gitHead": "556bcf2a422abe3d198bc8499255aaf5f0db7e45"
30
30
  }