@symbo.ls/cli 2.11.353 → 2.11.365

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 (2) hide show
  1. package/bin/fs.js +8 -5
  2. package/package.json +2 -2
package/bin/fs.js CHANGED
@@ -2,9 +2,11 @@ import fs from 'fs'
2
2
  import chalk from 'chalk'
3
3
  import path from 'path'
4
4
  import utils from '@domql/utils'
5
+ import * as smblsUtils from '@symbo.ls/utils'
5
6
  import inquirer from 'inquirer'
6
7
  import { createPatch } from 'diff'
7
8
 
9
+ const { removeChars, toCamelCase } = smblsUtils.default
8
10
  const { deepDestringify, objectToString, joinArrays, isString } = utils
9
11
 
10
12
  const LOCAL_CONFIG_PATH =
@@ -125,7 +127,8 @@ export async function createFs (
125
127
  }
126
128
 
127
129
  async function createOrUpdateFile (dirPath, childKey, value, update) {
128
- const filePath = path.join(dirPath, `${childKey}.js`)
130
+ const cleanKey = childKey.includes('-') || childKey.includes('/') ? removeChars(toCamelCase(childKey)) : childKey
131
+ const filePath = path.join(dirPath, `${childKey.replace('/', '-')}.js`)
129
132
 
130
133
  if (!update && fs.existsSync(filePath)) {
131
134
  return
@@ -133,10 +136,10 @@ export async function createFs (
133
136
 
134
137
  let stringifiedContent
135
138
  if (isString(value)) {
136
- stringifiedContent = `export const ${childKey} = ${value}`
139
+ stringifiedContent = `export const ${cleanKey} = ${value}`
137
140
  } else {
138
141
  const content = deepDestringify(value)
139
- stringifiedContent = `export const ${childKey} = ${objectToString(content)};`
142
+ stringifiedContent = `export const ${cleanKey} = ${objectToString(content)};`
140
143
  }
141
144
 
142
145
  await fs.promises.writeFile(filePath, stringifiedContent, 'utf8')
@@ -259,9 +262,9 @@ async function generateIndexjsFile (dirs, dirPath, key) {
259
262
  let indexContent
260
263
  if (key === 'pages') {
261
264
  indexContent =
262
- dirs.map((d) => `import { ${d} } from './${d}';`).join('\n') + '\n' +
265
+ dirs.map((d) => `import { ${d.includes('-') || d.includes('/') ? removeChars(toCamelCase(d)) : d} } from './${d.replace('/', '-')}';`).join('\n') + '\n' +
263
266
  `export default {
264
- ${dirs.map((d) => `'/${d === 'main' ? '' : d}': ${d},`).join('\n') + '\n'}
267
+ ${dirs.map((d) => `'/${d === 'main' ? '' : d}': ${d.includes('-') || d.includes('/') ? removeChars(toCamelCase(d)) : d},`).join('\n') + '\n'}
265
268
  }`
266
269
  } else if (key === 'root') {
267
270
  indexContent =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.11.353",
3
+ "version": "2.11.365",
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": "c5d01a30797fc044b539a5309a879f6b249e3888"
29
+ "gitHead": "27ab0a87d9a8ccf8eb50512b96b3015e15610910"
30
30
  }