@symbo.ls/cli 2.11.59 → 2.11.61

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
@@ -1,8 +1,20 @@
1
1
  'use strict'
2
2
 
3
+ import chalk from 'chalk'
4
+ import fs from 'fs'
5
+ import path from 'path'
3
6
  import { execSync } from 'child_process'
4
7
  import { program } from './program.js'
5
- import { initRepo } from './init-helpers/init-repo.js'
8
+ import { addToJson } from './init-helpers/addToJson.js'
9
+
10
+ function folderExists (path) {
11
+ try {
12
+ fs.accessSync(path, fs.constants.F_OK)
13
+ return true // The folder exists
14
+ } catch (err) {
15
+ return false // The folder does not exist
16
+ }
17
+ }
6
18
 
7
19
  const REPO_URLS = {
8
20
  domql: 'https://github.com/symbo-ls/starter-kit',
@@ -16,12 +28,12 @@ program
16
28
  .command('create')
17
29
  .description('Create and initialize a new project')
18
30
  .argument('dest', 'Project directory')
19
- .option('--domql', 'Use DOMQL in the project')
20
- .option('--react', 'Use React in the project (default)', true)
31
+ .option('--domql', 'Use DOMQL in the project', true)
32
+ .option('--react', 'Use React in the project (default)')
21
33
  .option('--angular', 'Use Angular in the project')
22
34
  .option('--vue2', 'Use Vue2 in the project')
23
35
  .option('--vue3', 'Use Vue3 in the project')
24
- .action(async (dest, options) => {
36
+ .action(async (dest = 'symbols-starter-kit', options) => {
25
37
  // Determine framework
26
38
  let framework = 'domql'
27
39
  if (options.react) {
@@ -35,10 +47,23 @@ program
35
47
  }
36
48
  const cloneUrl = REPO_URLS[framework]
37
49
 
38
- // Clone
50
+ if (folderExists(dest)) {
51
+ console.error(`Folder ${dest} already exists!`)
52
+ return
53
+ }
54
+
39
55
  console.log(`Cloning ${cloneUrl} into '${dest}'...`)
40
56
  execSync(`git clone ${cloneUrl} ${dest}`)
41
57
 
42
- // Leave the rest to init
43
- return await initRepo(dest, framework)
58
+ process.chdir(dest)
59
+
60
+ const SYMBOLS_FILE_PATH = path.join(process.cwd(), 'symbols.json')
61
+ addToJson(SYMBOLS_FILE_PATH, 'key', `${dest}.symbo.ls`)
62
+
63
+ console.log('Installing Dependencies...')
64
+ console.log()
65
+ execSync('npm i')
66
+ console.log()
67
+ console.log(chalk.green.bold(dest), 'successfuly created!')
68
+ console.log(`Done! run \`${chalk.bold('npm start')}\` to start the development server.`)
44
69
  })
@@ -1,14 +1,15 @@
1
1
  export const CustomDesignSystem = {
2
- color: {
3
- snowWhite: '#F3F6FB'
4
- },
5
- theme: {},
6
- typography: {},
7
- space: {},
8
- media: {},
9
- icons: {},
10
- font: {},
11
- font_family: {},
12
- timing: {},
13
- reset: {}
2
+ ANIMATION: {},
3
+ COLOR: {},
4
+ GRADIENT: {},
5
+ THEME: {},
6
+ TYPOGRAPHY: {},
7
+ SPACING: {},
8
+ SVG: {},
9
+ ICONS: {},
10
+ FONT: {},
11
+ FONT_FAMILY: {},
12
+ TIMING: {},
13
+ MEDIA: {},
14
+ RESET: {}
14
15
  }
@@ -0,0 +1,28 @@
1
+ 'use strict'
2
+
3
+ import fs from 'fs'
4
+
5
+ // Step 1: Read the JSON file
6
+ export const addToJson = (filePath, key, value) => {
7
+ fs.readFile(filePath, 'utf8', (err, data) => {
8
+ if (err) {
9
+ console.error('Error reading file:', err)
10
+ return
11
+ }
12
+
13
+ try {
14
+ const jsonData = JSON.parse(data)
15
+
16
+ jsonData[key] = value
17
+
18
+ fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 2), 'utf8', err => {
19
+ if (err) {
20
+ console.error('Error writing file:', err)
21
+ }
22
+ console.log(filePath, JSON.stringify(jsonData, null, 2))
23
+ })
24
+ } catch (parseError) {
25
+ console.error('Error parsing JSON:', parseError)
26
+ }
27
+ })
28
+ }
@@ -1,11 +1,16 @@
1
1
  'use strict'
2
2
 
3
- import { execSync } from 'child_process'
3
+ import chalk from 'chalk'
4
4
  import fs from 'fs'
5
5
  import path from 'path'
6
+ import { execSync } from 'child_process'
6
7
  import { fileURLToPath } from 'url'
8
+ import { addToJson } from './addToJson.js'
9
+
7
10
  const __filename = fileURLToPath(import.meta.url)
8
11
  const __dirname = path.dirname(__filename)
12
+ const SYMBOLS_FILE_PATH = path.join(
13
+ __dirname, 'symbols.json')
9
14
  const DESIGN_SYSTEM_FILE_PATH = path.join(
10
15
  __dirname, 'DesignSystem.js')
11
16
 
@@ -20,18 +25,38 @@ export async function initRepo (dest, framework) {
20
25
  process.chdir(cwd)
21
26
  }
22
27
 
28
+ // Determine framework
29
+ let pkg = 'smbls'
30
+ if (framework === 'react') {
31
+ pkg = '@symbo.ls/react'
32
+ } else if (framework === 'angular') {
33
+ pkg = '@symbo.ls/react'
34
+ } else if (framework === 'vue2') {
35
+ pkg = '@symbo.ls/vue2'
36
+ } else if (framework === 'vue3') {
37
+ pkg = '@symbo.ls/vue3'
38
+ }
39
+
23
40
  // TODO: inject smbls dependencies into package.json
24
41
 
25
42
  // Install
26
- console.log('Installing NPM dependencies...')
43
+ console.log(`Installing \`${pkg}\` from NPM...`)
27
44
  process.chdir(dest)
28
- execSync('npm install', { stdio: ['inherit', 'inherit', 'ignore'] })
45
+ // execSync(`npm i ${pkg} --save`)
29
46
  process.chdir(cwd)
30
47
 
31
48
  // Copy design system file
32
- const filePath = path.join(dest, 'DesignSystem.js')
33
- console.log(`Writing DesignSystem.js to ${filePath}`)
34
- await fs.promises.copyFile(DESIGN_SYSTEM_FILE_PATH, filePath)
49
+ console.log()
50
+ const dsfilePath = path.join(dest, 'DesignSystem.js')
51
+ console.log('Creating', chalk.bold(dsfilePath))
52
+ await fs.promises.copyFile(DESIGN_SYSTEM_FILE_PATH, dsfilePath)
53
+
54
+ // Copy design system file
55
+ const rcfilePath = path.join(dest, 'symbols.json')
56
+ console.log('Creating', chalk.bold(rcfilePath))
57
+ await fs.promises.copyFile(SYMBOLS_FILE_PATH, rcfilePath)
58
+ if (framework !== 'domql') addToJson(SYMBOLS_FILE_PATH, 'framework', framework)
59
+ console.log()
35
60
 
36
- console.log('Done!')
61
+ console.log(chalk.green.bold('Initialized project successfully.'))
37
62
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "key": "projectKey.symbo.ls"
3
+ }
package/bin/init.js CHANGED
@@ -7,8 +7,8 @@ program
7
7
  .command('init')
8
8
  .description('Initialize a project')
9
9
  .argument('[dest]', 'Project directory. By default, it is "."')
10
- .option('--domql', 'Use Domql in the project')
11
- .option('--react', 'Use React in the project (default)', true)
10
+ .option('--domql', 'Use Domql in the project', true)
11
+ .option('--react', 'Use React in the project (default)')
12
12
  .option('--angular', 'Use Angular in the project')
13
13
  .option('--vue2', 'Use Vue2 in the project')
14
14
  .option('--vue3', 'Use Vue3 in the project')
@@ -16,9 +16,9 @@ program
16
16
  if (!dest) dest = '.'
17
17
 
18
18
  // Determine framework
19
- let framework = 'react'
20
- if (options.domql) {
21
- framework = 'domql'
19
+ let framework = 'domql'
20
+ if (options.react) {
21
+ framework = 'react'
22
22
  } else if (options.angular) {
23
23
  framework = 'angular'
24
24
  } else if (options.vue2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/cli",
3
- "version": "2.11.59",
3
+ "version": "2.11.61",
4
4
  "description": "Fetch your Symbols configuration",
5
5
  "main": "bin/fetch.js",
6
6
  "author": "Symbols",
@@ -27,5 +27,5 @@
27
27
  "peerDependencies": {
28
28
  "domql-to-mitosis": "latest"
29
29
  },
30
- "gitHead": "285850864e56374f450c1f18e497b3886aa70e03"
30
+ "gitHead": "8e1db51c5601f1d344cfbaea5adbfd6a91e7407f"
31
31
  }