@symbo.ls/cli 2.11.159 → 2.11.160

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/convert.js +50 -50
  2. package/package.json +2 -2
package/bin/convert.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
-
2
+ // TODO: --only flag doesn't work!!!
3
3
  import { program } from './program.js'
4
4
  import { convert } from 'kalduna'
5
5
  import { parse } from 'globusa'
@@ -38,7 +38,7 @@ const INTERNAL_UIKIT_CONF = {
38
38
  'DatePickerGridContainer',
39
39
 
40
40
  // Not a domql object (headless-datepicker)
41
- 'calendar',
41
+ 'calendar'
42
42
  ],
43
43
 
44
44
  // Can be strings or regex patterns
@@ -46,8 +46,8 @@ const INTERNAL_UIKIT_CONF = {
46
46
  // TODO: Review these ignores with @nikoloza
47
47
  /Threejs$/,
48
48
  /Editorjs$/,
49
- /User$/,
50
- ],
49
+ /User$/
50
+ ]
51
51
  }
52
52
  const TMP_DIR_NAME = '.smbls_convert_tmp'
53
53
  const TMP_DIR_PACKAGE_JSON_STR = JSON.stringify({
@@ -57,7 +57,7 @@ const TMP_DIR_PACKAGE_JSON_STR = JSON.stringify({
57
57
  license: 'ISC'
58
58
  })
59
59
 
60
- function generatePackageJsonFile(
60
+ function generatePackageJsonFile (
61
61
  sourcePackageJsonPath,
62
62
  destPath,
63
63
  globusaStruct,
@@ -71,7 +71,7 @@ function generatePackageJsonFile(
71
71
  packageStruct = JSON.parse(str)
72
72
  } catch (error) {
73
73
  console.error(`Error when parsing ${sourcePackageJsonPath}`)
74
- return;
74
+ return
75
75
  }
76
76
  const split = packageStruct.name.split('/')
77
77
  const packageName = split[split.length - 1]
@@ -82,12 +82,12 @@ function generatePackageJsonFile(
82
82
  [`@emotion/${desiredFormat}`]: '^11.11.0',
83
83
  '@emotion/css': '^11.11.0',
84
84
  '@symbo.ls/create': 'latest',
85
- '@symbo.ls/react': 'latest',
85
+ '@symbo.ls/react': 'latest'
86
86
  }
87
87
  globusaStruct.imports
88
88
  .filter(imp => imp.path.match(/^@symbo\.ls\//))
89
89
  .filter(imp => imp.path !== packageName)
90
- .forEach(imp => deps[imp.path] = 'latest')
90
+ .forEach(imp => { deps[imp.path] = 'latest' })
91
91
 
92
92
  // Generate final package.json string
93
93
  const genStr = JSON.stringify({
@@ -96,7 +96,7 @@ function generatePackageJsonFile(
96
96
  license: packageStruct.license ?? 'UNLICENSED',
97
97
  dependencies: deps,
98
98
  peerDependencies: {
99
- 'react': '^18.2.0',
99
+ react: '^18.2.0',
100
100
  'react-dom': '^18.2.0'
101
101
  },
102
102
  main: 'index.js',
@@ -126,30 +126,29 @@ async function mkdirp (dir) {
126
126
  }
127
127
 
128
128
  // Returns a string
129
- function convertDomqlModule(domqlModule, globusaStruct, desiredFormat, options) {
129
+ function convertDomqlModule (domqlModule, globusaStruct, desiredFormat, options) {
130
130
  let convertedStr = ''
131
131
  const whitelist = (options.only ? options.only.split(',') : null)
132
132
 
133
133
  console.group()
134
134
  const exports = Object.keys(domqlModule)
135
- .filter(exportName => {
136
- if (!whitelist) return true
137
- if (whitelist.includes(exportName)) {
138
- console.log(`Skipping ${exportName} component due to whitelist exclusion`)
139
- return false
140
- }
141
- return true
142
- })
143
- .filter(exportName => {
144
- if (!options.internalUikit) return true
145
- if (INTERNAL_UIKIT_CONF.excludedComponents.includes(exportName)) {
146
- console.log(`Skipping ${exportName} component due to internal uikit exclusion`)
147
- return false
148
- }
149
- return true
150
- })
151
-
152
- const isSingleComponent = (exports.length === 1)
135
+ .filter(exportName => {
136
+ if (!whitelist) return true
137
+ if (whitelist.includes(exportName)) {
138
+ console.log(`Skipping ${exportName} component due to whitelist exclusion`)
139
+ return false
140
+ }
141
+ return true
142
+ })
143
+ .filter(exportName => {
144
+ if (!options.internalUikit) return true
145
+ if (INTERNAL_UIKIT_CONF.excludedComponents.includes(exportName)) {
146
+ console.log(`Skipping ${exportName} component due to internal uikit exclusion`)
147
+ return false
148
+ }
149
+ return true
150
+ })
151
+
153
152
  const uniqueImports = []
154
153
  let globalSymbolTable = {}
155
154
  for (const idx in exports) {
@@ -163,16 +162,17 @@ function convertDomqlModule(domqlModule, globusaStruct, desiredFormat, options)
163
162
  }
164
163
 
165
164
  console.group()
166
- console.log(dobj.__name) // NOTE(Nikaoto): @nikoloza, don't remove this
165
+ console.log(dobj.__name) // NOTE: Don't remove this
167
166
 
168
- const isFirst = (idx == 0)
169
- const isLast = (idx == (exports.length - 1)) // NOTE: Don't use '===' here!
167
+ // NOTE: Don't use '===' here!
168
+ const isFirst = (idx == 0) // eslint-disable-line
169
+ const isLast = (idx == (exports.length - 1)) // eslint-disable-line
170
170
 
171
171
  const kaldunaOpts = {
172
172
  verbose: false,
173
173
  returnMitosisIR: true,
174
174
  globalSymbolTable,
175
- exportDefault: isSingleComponent,
175
+ exportDefault: false,
176
176
  importsToRemove: uniqueImports,
177
177
 
178
178
  /* NOTE: The option below prevents a name collision bug. For example:
@@ -184,14 +184,14 @@ function convertDomqlModule(domqlModule, globusaStruct, desiredFormat, options)
184
184
  But, in this case, because A is in local scope as one of the exports,
185
185
  the component import will be ignored, preventing the collision.
186
186
  */
187
- componentImportsToIgnore: exports,
187
+ componentImportsToIgnore: exports
188
188
  }
189
189
 
190
190
  let out = null
191
191
  if (isFirst) {
192
192
  out = convert(dobj, desiredFormat, {
193
193
  ...kaldunaOpts,
194
- removeReactImport: false,
194
+ removeReactImport: false
195
195
  // NOTE(nikaoto): Commented these out because we're using deps now, so
196
196
  // all the imports and decls are going to be redundant
197
197
  // importsToInclude: globusaStruct.imports,
@@ -200,7 +200,7 @@ function convertDomqlModule(domqlModule, globusaStruct, desiredFormat, options)
200
200
  } else {
201
201
  out = convert(dobj, desiredFormat, {
202
202
  ...kaldunaOpts,
203
- removeReactImport: true,
203
+ removeReactImport: true
204
204
  })
205
205
  }
206
206
 
@@ -221,8 +221,8 @@ function convertDomqlModule(domqlModule, globusaStruct, desiredFormat, options)
221
221
  // result to the destination. The tmpDirPath is used as a working directory for
222
222
  // temporary files.
223
223
  // Returns globusaStruct for later usage.
224
- async function convertFile(srcPath, tmpDirPath, destPath,
225
- desiredFormat, options) {
224
+ async function convertFile (srcPath, tmpDirPath, destPath,
225
+ desiredFormat, options) {
226
226
  // Parse with globusa
227
227
  console.log(`Parsing components in ${srcPath}`)
228
228
  const fileContent = await fs.promises.readFile(srcPath, 'utf8')
@@ -236,6 +236,7 @@ async function convertFile(srcPath, tmpDirPath, destPath,
236
236
  entryPoints: [srcPath],
237
237
  bundle: true,
238
238
  sourcemap: true,
239
+ keepNames: false,
239
240
  target: 'node12',
240
241
  format: 'cjs',
241
242
  outdir: tmpDirPath
@@ -273,20 +274,20 @@ program
273
274
  .description('Convert and copy all DomQL components under a directory')
274
275
  .argument('[src]', 'Source directory/file. By default, it is "src/"')
275
276
  .argument('[dest]',
276
- 'Destination directory/file. Will be overwritten. By ' +
277
+ 'Destination directory/file. Will be overwritten. By ' +
277
278
  'default, it becomes the name of the desired format')
278
279
  .option('--react', 'Convert all DomQL components to React')
279
280
  .option('--angular', 'Convert all DomQL components to Angular')
280
281
  .option('--vue2', 'Convert all DomQL components to Vue2')
281
282
  .option('--vue3', 'Convert all DomQL components to Vue3')
282
283
  .option('-t, --tmp-dir <path>',
283
- 'Use this directory for storing intermediate & build files instead of ' +
284
+ 'Use this directory for storing intermediate & build files instead of ' +
284
285
  `the default (dest/${TMP_DIR_NAME})`)
285
286
  .option('-o, --only <components>',
286
- 'Only convert these components; comma separated ' +
287
+ 'Only convert these components; comma separated ' +
287
288
  '(for example: --only=Flex,Img)')
288
289
  .option('--internal-uikit',
289
- '(For internal use only). ' +
290
+ '(For internal use only). ' +
290
291
  'Excludes particular components from the conversion')
291
292
  .action(async (src, dest, options) => {
292
293
  if (!convert) {
@@ -386,7 +387,7 @@ program
386
387
 
387
388
  const ignoredFiles = ['index.js', 'package.json', 'node_modules', 'dist']
388
389
  const sourceDirNames = (await fs.promises.readdir(srcPath))
389
- .filter(dir => !ignoredFiles.includes(dir))
390
+ .filter(dir => !ignoredFiles.includes(dir))
390
391
 
391
392
  const dirs = []
392
393
 
@@ -394,8 +395,7 @@ program
394
395
  // Ignored directories
395
396
  if (options.internalUikit) {
396
397
  let skip = false
397
- for (const pat of INTERNAL_UIKIT_CONF.excludedDirectories)
398
- if (dir.match(pat)) { skip = true; break; }
398
+ for (const pat of INTERNAL_UIKIT_CONF.excludedDirectories) { if (dir.match(pat)) { skip = true; break } }
399
399
  if (skip) continue
400
400
  }
401
401
 
@@ -408,8 +408,8 @@ program
408
408
  const pjFilePath = path.join(dirPath, 'package.json')
409
409
 
410
410
  const globusaStruct = await convertFile(
411
- indexFilePath, // src
412
- path.join(tmpDirPath, dir), // tmp
411
+ indexFilePath, // src
412
+ path.join(tmpDirPath, dir), // tmp
413
413
  path.join(destDirPath, dir, 'index.js'), // dst
414
414
  desiredFormat,
415
415
  options
@@ -417,7 +417,7 @@ program
417
417
 
418
418
  if (fs.existsSync(pjFilePath)) {
419
419
  generatePackageJsonFile(
420
- pjFilePath, // src
420
+ pjFilePath, // src
421
421
  path.join(destDirPath, dir, 'package.json'), // dst
422
422
  globusaStruct,
423
423
  desiredFormat,
@@ -430,9 +430,9 @@ program
430
430
 
431
431
  // Generate top index.js file
432
432
  if (dirs.length > 0) {
433
- //const importLines = dirs.map(d => `import ${d} from './${d}'`).join('\n') + '\n'
434
- //const exportLines = 'export {\n' + dirs.map(d => ` ${d}`).join(',\n') + '\n}\n'
435
- //const fileContent = importLines + '\n' + exportLines
433
+ // const importLines = dirs.map(d => `import ${d} from './${d}'`).join('\n') + '\n'
434
+ // const exportLines = 'export {\n' + dirs.map(d => ` ${d}`).join(',\n') + '\n}\n'
435
+ // const fileContent = importLines + '\n' + exportLines
436
436
  const fileContent = dirs.map(d => `export * from './${d}'`).join('\n')
437
437
 
438
438
  const fh = await fs.promises.open(path.join(destDirPath, 'index.js'), 'w')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.11.159",
3
+ "version": "2.11.160",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "bin/fetch.js",
6
6
  "author": "Symbols",
@@ -25,5 +25,5 @@
25
25
  "node-fetch": "^3.1.0",
26
26
  "v8-compile-cache": "^2.3.0"
27
27
  },
28
- "gitHead": "4dbce17a65f09e9c7e9451f5d9042ddbe351280b"
28
+ "gitHead": "f36bc99a2d0c1b771e3d8e104d1b1005b2b0a33a"
29
29
  }