@iankibetsh/shframework 1.3.7 → 1.3.9

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/package.json +2 -2
  2. package/src/lib/cmds/cli.js +33 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",
@@ -16,7 +16,7 @@
16
16
  "serve": "vite"
17
17
  },
18
18
  "bin": {
19
- "sh-set-defaults": "./src/lib/cmds/cli.js"
19
+ "sh-copy-defaults": "./src/lib/cmds/cli.js"
20
20
  },
21
21
  "keywords": [],
22
22
  "author": "",
@@ -1,18 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs')
3
+ const components = require('../repo/helpers/components.js')
4
+
3
5
  const [,, ... args] = process.argv
4
6
  const templatesDir =`${__dirname}/../components/form-components/`
5
7
  const destination = `${process.cwd()}/src/components/form-components/`
6
- console.log(`Copying form component files to ${destination}`)
7
- !fs.existsSync(destination) && fs.mkdirSync(destination,{ recursive: true })
8
-
9
- fs.readdirSync(templatesDir).map(file=>{
10
- console.log(`cp ${file}`)
11
- const src = `${templatesDir}${file}`
12
- const dest = `${destination}${file}`
13
- let contents = fs.readFileSync(src,'utf8')
14
- contents = contents.replace(`import shApis from '../../repo/helpers/ShApis.js'`,`import { shApis } from '@iankibetsh/shframework'`)
15
- contents = contents.replace(`import countries from '../../repo/helpers/countries.js'`,`import { countries } from '@iankibetsh/shframework'`)
16
- fs.writeFileSync(dest,contents)
17
- })
18
- console.log("DONE")
8
+ if(fs.existsSync(templatesDir)){
9
+ console.log('Creating component backup')
10
+ const jsBackupFile =`${__dirname}/../repo/helpers/components.js`
11
+ !fs.existsSync(destination) && fs.mkdirSync(destination,{ recursive: true })
12
+ console.log(args)
13
+ const components = []
14
+ fs.readdirSync(templatesDir).map(file=>{
15
+ console.log(`File - ${file}`)
16
+ const src = `${templatesDir}${file}`
17
+ let contents = fs.readFileSync(src,'utf8')
18
+ contents = contents.replace(`import shApis from '../../repo/helpers/ShApis.js'`,`import { shApis } from '@iankibetsh/shframework'`)
19
+ contents = contents.replace(`import countries from '../../repo/helpers/countries.js'`,`import { countries } from '@iankibetsh/shframework'`)
20
+ components.push({
21
+ fileName: file,
22
+ contents: contents
23
+ })
24
+ //
25
+ })
26
+ const contents = `exports.components = ` + JSON.stringify(components)
27
+ fs.writeFileSync(jsBackupFile,contents)
28
+ console.log("DONE")
29
+ } else {
30
+ console.log(`Copying form component files to ${destination}`)
31
+ components.components.map(component=>{
32
+ const file = component.fileName
33
+ const contents = component.contents
34
+ const dest = `${destination}${file}`
35
+ console.log(`Copy ${file} to ${destination}`)
36
+ fs.writeFileSync(dest,contents)
37
+ })
38
+ }