@symbo.ls/cli 2.29.70 → 2.29.72

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 +39 -21
  2. package/package.json +5 -5
package/bin/fs.js CHANGED
@@ -6,7 +6,8 @@ import * as smblsUtils from '@symbo.ls/utils'
6
6
  import inquirer from 'inquirer'
7
7
  import { createPatch } from 'diff'
8
8
 
9
- const { removeChars, toCamelCase, toTitleCase } = (smblsUtils.default || smblsUtils)
9
+ const { removeChars, toCamelCase, toTitleCase } =
10
+ smblsUtils.default || smblsUtils
10
11
  const {
11
12
  deepDestringify,
12
13
  objectToString,
@@ -14,14 +15,27 @@ const {
14
15
  isString,
15
16
  isObject,
16
17
  removeValueFromArray
17
- } = (utils.default || utils)
18
+ } = utils.default || utils
18
19
 
19
20
  let singleFileKeys = ['designSystem', 'state', 'files', 'dependencies']
20
- const directoryKeys = ['components', 'snippets', 'pages', 'functions', 'methods']
21
-
22
- const defaultExports = ['pages', 'designSystem', 'state', 'files', 'dependencies', 'schema']
23
-
24
- export async function createFs (
21
+ const directoryKeys = [
22
+ 'components',
23
+ 'snippets',
24
+ 'pages',
25
+ 'functions',
26
+ 'methods'
27
+ ]
28
+
29
+ const defaultExports = [
30
+ 'pages',
31
+ 'designSystem',
32
+ 'state',
33
+ 'files',
34
+ 'dependencies',
35
+ 'schema'
36
+ ]
37
+
38
+ export async function createFs(
25
39
  body,
26
40
  distDir = path.join(process.cwd(), 'smbls'),
27
41
  opts = {}
@@ -121,7 +135,7 @@ export async function createFs (
121
135
  }
122
136
  }
123
137
 
124
- async function createKeyDirectoryAndFiles (key, body, distDir, update) {
138
+ async function createKeyDirectoryAndFiles(key, body, distDir, update) {
125
139
  const dirPath = path.join(distDir, key)
126
140
  await fs.promises.mkdir(dirPath, { recursive: true })
127
141
 
@@ -146,7 +160,7 @@ export async function createFs (
146
160
  await generateIndexjsFile(dirs, dirPath, key)
147
161
  }
148
162
 
149
- async function createOrUpdateFile (dirPath, childKey, value, update) {
163
+ async function createOrUpdateFile(dirPath, childKey, value, update) {
150
164
  const itemKey =
151
165
  childKey.includes('-') || childKey.includes('/')
152
166
  ? removeChars(toCamelCase(childKey))
@@ -158,7 +172,9 @@ export async function createFs (
158
172
  }
159
173
 
160
174
  const itemKeyInvalid = itemKey.includes('.')
161
- const validKey = itemKeyInvalid ? `const ${removeChars(toTitleCase(itemKey))}` : `export const ${itemKey}`
175
+ const validKey = itemKeyInvalid
176
+ ? `const ${removeChars(toTitleCase(itemKey))}`
177
+ : `export const ${itemKey}`
162
178
 
163
179
  let stringifiedContent
164
180
  if (isString(value)) {
@@ -167,9 +183,7 @@ export async function createFs (
167
183
  const content = deepDestringify(value)
168
184
  // console.log('ON DEEPDESTR:')
169
185
  // console.log(content.components.Configuration)
170
- stringifiedContent = `${validKey} = ${objectToString(
171
- content
172
- )};`
186
+ stringifiedContent = `${validKey} = ${objectToString(content)};`
173
187
  }
174
188
 
175
189
  if (itemKeyInvalid) {
@@ -181,7 +195,7 @@ export { ${removeChars(toTitleCase(itemKey))} as '${itemKey}' }`
181
195
  await fs.promises.writeFile(filePath, stringifiedContent, 'utf8')
182
196
  }
183
197
 
184
- async function createSingleFileFolderAndFile (key, data, distDir, update) {
198
+ async function createSingleFileFolderAndFile(key, data, distDir, update) {
185
199
  const filePath = path.join(distDir, `${key}.js`)
186
200
 
187
201
  if (!update && fs.existsSync(filePath)) {
@@ -214,7 +228,7 @@ export { ${removeChars(toTitleCase(itemKey))} as '${itemKey}' }`
214
228
  // }
215
229
  }
216
230
 
217
- async function findDiff (targetDir, distDir) {
231
+ async function findDiff(targetDir, distDir) {
218
232
  const diffs = []
219
233
 
220
234
  for (const key of directoryKeys) {
@@ -289,7 +303,7 @@ async function findDiff (targetDir, distDir) {
289
303
  return diffs
290
304
  }
291
305
 
292
- async function generateIndexjsFile (dirs, dirPath, key) {
306
+ async function generateIndexjsFile(dirs, dirPath, key) {
293
307
  let indexContent
294
308
  if (key === 'pages') {
295
309
  indexContent =
@@ -322,19 +336,23 @@ async function generateIndexjsFile (dirs, dirPath, key) {
322
336
  indexContent =
323
337
  dirs
324
338
  .map((d) => {
339
+ const dirOrSingleJs = directoryKeys.includes(d)
340
+ ? d + '/index.js'
341
+ : d + '.js'
325
342
  if (defaultExports.includes(d)) {
326
- return `export { default as ${d} } from './${d}';`
327
- } else return `export * as ${d} from './${d}';`
343
+ return `export { default as ${d} } from './${dirOrSingleJs}';`
344
+ } else return `export * as ${d} from './${dirOrSingleJs}';`
328
345
  })
329
346
  .join('\n') + '\n'
330
347
  } else {
331
- indexContent = dirs.map((d) => `export * from './${d}';`).join('\n') + '\n'
348
+ indexContent =
349
+ dirs.map((d) => `export * from './${d}.js';`).join('\n') + '\n'
332
350
  }
333
351
  const indexFilePath = path.join(dirPath, 'index.js')
334
352
  await fs.promises.writeFile(indexFilePath, indexContent, 'utf8')
335
353
  }
336
354
 
337
- async function overrideFiles (targetDir, distDir) {
355
+ async function overrideFiles(targetDir, distDir) {
338
356
  for (const key of directoryKeys) {
339
357
  const targetDirPath = path.join(targetDir, key)
340
358
  const distDirPath = path.join(distDir, key)
@@ -364,7 +382,7 @@ async function overrideFiles (targetDir, distDir) {
364
382
  }
365
383
  }
366
384
 
367
- async function askForConsent () {
385
+ async function askForConsent() {
368
386
  const questions = [
369
387
  {
370
388
  type: 'confirm',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.29.70",
3
+ "version": "2.29.72",
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": "^2.29.70",
19
- "@symbo.ls/init": "^2.29.70",
20
- "@symbo.ls/socket": "^2.29.70",
18
+ "@symbo.ls/fetch": "^2.29.72",
19
+ "@symbo.ls/init": "^2.29.72",
20
+ "@symbo.ls/socket": "^2.29.72",
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": "1407af1db22e20fafb2f7c7a5f9259a97c2dbb26"
29
+ "gitHead": "cc55625588e16c546fc22607d4e1c4bca46661e6"
30
30
  }