@reactful/create 0.0.69 → 0.0.71

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/index.js +14 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { exec } from 'child_process'
3
+ import { execSync } from 'child_process'
4
4
  import inquirer from 'inquirer'
5
5
  import fetch from 'node-fetch'
6
6
  import path from 'path'
@@ -32,17 +32,16 @@ const questions = [
32
32
  ]
33
33
 
34
34
  inquirer.prompt(questions).then(async function (answers) {
35
- exec(`md ${answers.project}`)
36
- exec(`cd ${answers.project}`)
37
-
35
+ fs.mkdirSync(answers.project)
36
+
38
37
  const destination = path.join(process.cwd(), answers.project)
39
-
38
+
40
39
  await downloadRepo(`commons`, destination)
41
40
  await downloadRepo(`templates/${answers.template}`, destination)
42
-
41
+
43
42
  renamingJSON(destination, answers.project)
44
-
45
- exec(`bun install`)
43
+
44
+ execSync(`cd ${answers.project}; bun install`)
46
45
  })
47
46
 
48
47
  function renamingJSON(directory, projectName) {
@@ -60,15 +59,16 @@ function renamingJSON(directory, projectName) {
60
59
  const downloadRepo = async (subfolder, destination) =>
61
60
  downloadGitHub('jsenaribeiro', 'reactful', subfolder, destination)
62
61
 
63
- async function downloadGitHub(user, repository, subfolder, destination) {
62
+ async function downloadGitHub(user, repository, subdir, destination) {
64
63
  const prefix = `https://api.github.com/repos/${user}/${repository}`
65
- const url = `${prefix}/contents/installation/${subfolder}`
66
- const content = await fetch(url).then(x => x.json())
64
+ const url = `${prefix}/contents/installation/${subdir}`
65
+ const contents = await fetch(url).then(x => x.json())
67
66
 
68
- console.log('- url', url)
69
- console.log('- res', JSON.stringify(content))
67
+ for (const item of contents) {
68
+ const from = `${subdir}/${item.name}`
69
+ const goto = `${destination}/${item.name}`
70
70
 
71
- for (const item of content) {
71
+ if (item.type === 'dir') await downloadGitHub(from, goto)
72
72
  if (item.type != 'file') continue
73
73
 
74
74
  const filename = path.join(destination, item.name)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactful/create",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "description": "reactful scafold tool",