@reactful/create 0.1.10 → 0.1.12

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/index.js CHANGED
@@ -38,22 +38,21 @@ async function prompting(answers) {
38
38
  if (!answers.project) throw 'Required project name!'
39
39
 
40
40
  const destination = path.join(process.cwd(), answers.project)
41
- const temporaryPath = path.join(destination, 'temp')
41
+ const downloadPath = path.join(destination, 'temp')
42
42
 
43
43
  await createDirectory(destination)
44
44
 
45
45
  console.log('- loading NPM...')
46
- await download('@reactful/create', temporaryPath)
46
+ await download('@reactful/create', downloadPath)
47
47
 
48
48
  console.log('- creating .env...')
49
49
  const env = `PORT=333\nMINIFY=FALSE`
50
50
  fs.writeFileSync(`${destination}/.env`, env)
51
51
 
52
52
  console.log('- copying template...')
53
- await copyTemplate(temporaryPath, `commons`, destination)
54
- await copyTemplate(temporaryPath, `templates/${answers.template}`, destination)
55
- await removeDirectory(temporaryPath)
56
-
53
+ await copyPath(`${downloadPath}/commons`, destination)
54
+ await copyPath(`${downloadPath}/templates/${answers.template}`, destination)
55
+
57
56
  console.log('- renaming project...')
58
57
  renamingJSON(destination, answers.project)
59
58
 
@@ -61,14 +60,15 @@ async function prompting(answers) {
61
60
  process.chdir(answers.project)
62
61
  execSync(`bun install`)
63
62
 
64
- try {
65
- answers.vscode
66
- ? spawn("code", ['.'])
67
- : spawn("cd", [answers.project])
68
- }
69
- catch (ex) {
70
- console.error('prompting', ex)
63
+ if (answers.vscode) {
64
+ spawn("code", ['.'])
65
+
66
+ const pathVSCode = `${destination}/.vscode`
67
+ await createDirectory(pathVSCode)
68
+ await copyPath(`${downloadPath}/vscode`, pathVSCode)
71
69
  }
70
+
71
+ await removeDirectory(downloadPath)
72
72
  }
73
73
 
74
74
  function renamingJSON(directory, projectName) {
@@ -81,17 +81,6 @@ function renamingJSON(directory, projectName) {
81
81
  fs.writeFileSync(url, JSON.stringify(obj, null, 3))
82
82
  }
83
83
 
84
- async function copyTemplate(temporaryPath, subdirectory, destination) {
85
- try {
86
- const folder = path.join(temporaryPath, subdirectory)
87
- await copyFolder(folder, destination)
88
-
89
- } catch (error) {
90
- console.error('copyTemplate')
91
- throw error
92
- }
93
- }
94
-
95
84
  async function download(packageName, directory) {
96
85
  try {
97
86
  await createDirectory(directory)
@@ -134,7 +123,7 @@ function removeDirectory(directory) {
134
123
  else fs.rmSync(directory, { recursive: true })
135
124
  }
136
125
 
137
- function copyFolder(source, target) {
126
+ function copyPath(source, target) {
138
127
  if (!fs.existsSync(target)) fs.mkdirSync(target)
139
128
 
140
129
  fs.readdirSync(source).forEach(function (file) {
@@ -142,7 +131,7 @@ function copyFolder(source, target) {
142
131
  const targetPath = path.join(target, file)
143
132
 
144
133
  if (fs.lstatSync(currentPath).isDirectory())
145
- copyFolder(currentPath, targetPath)
134
+ copyPath(currentPath, targetPath)
146
135
 
147
136
  else fs.copyFileSync(currentPath, targetPath)
148
137
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactful/create",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "description": "reactful scafold tool",
@@ -12,7 +12,8 @@
12
12
  "index.js",
13
13
  "package.json",
14
14
  "templates",
15
- "commons"
15
+ "commons",
16
+ "vscode"
16
17
  ],
17
18
  "scripts": {
18
19
  "start": "bun run index.js",
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [{
4
+ "type": "bun",
5
+ "name": "Bun: Debug",
6
+ "request": "launch",
7
+ "program": "index.ts"
8
+ }]
9
+ }