makepack 1.3.7 → 1.3.8
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/README.md +146 -146
- package/package.json +56 -56
- package/src/actions/create/files/gitignore.js +5 -5
- package/src/actions/create/files/makepack.js +19 -19
- package/src/actions/create/files/package-json.js +42 -42
- package/src/actions/create/files/project-js.js +12 -12
- package/src/actions/create/files/project-jsx.js +50 -50
- package/src/actions/create/files/project-ts.js +10 -10
- package/src/actions/create/files/project-tsx.js +50 -50
- package/src/actions/create/files/readme.md.js +13 -13
- package/src/actions/create/files/serve.js +51 -51
- package/src/actions/create/files/tsconfig.js +32 -32
- package/src/actions/create/index.js +29 -29
- package/src/actions/create/makeFiles.js +64 -64
- package/src/actions/create/makeProjectDirectory.js +41 -41
- package/src/actions/create/makeProjectInformation.js +67 -67
- package/src/actions/pack/index.js +94 -110
- package/src/actions/serve/index.js +96 -106
- package/src/helpers.js +121 -69
- package/src/index.js +30 -30
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export default args => {
|
|
2
|
-
const content = `
|
|
3
|
-
function add(a: number, b: number): number {
|
|
4
|
-
return a + b;
|
|
5
|
-
}
|
|
6
|
-
export default add`
|
|
7
|
-
return {
|
|
8
|
-
content,
|
|
9
|
-
filename: `${args.rootdir}/${args.entry}`
|
|
10
|
-
}
|
|
1
|
+
export default args => {
|
|
2
|
+
const content = `
|
|
3
|
+
function add(a: number, b: number): number {
|
|
4
|
+
return a + b;
|
|
5
|
+
}
|
|
6
|
+
export default add`
|
|
7
|
+
return {
|
|
8
|
+
content,
|
|
9
|
+
filename: `${args.rootdir}/${args.entry}`
|
|
10
|
+
}
|
|
11
11
|
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
export default (args) => {
|
|
2
|
-
const content = `import React, { useState } from 'react';
|
|
3
|
-
|
|
4
|
-
const Count: React.FC = () => {
|
|
5
|
-
const [count, setCount] = useState<number>(0);
|
|
6
|
-
const increment = (): void => setCount(prevCount => prevCount + 1);
|
|
7
|
-
const decrement = (): void => setCount(prevCount => prevCount - 1);
|
|
8
|
-
const reset = (): void => setCount(0);
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<div style={styles.container}>
|
|
12
|
-
<h1>Count App</h1>
|
|
13
|
-
<div style={styles.counter}>{count}</div>
|
|
14
|
-
<div style={styles.buttonContainer}>
|
|
15
|
-
<button style={styles.button} onClick={increment}>Increment</button>
|
|
16
|
-
<button style={styles.button} onClick={decrement}>Decrement</button>
|
|
17
|
-
<button style={styles.button} onClick={reset}>Reset</button>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const styles: { [key: string]: React.CSSProperties } = {
|
|
24
|
-
container: {
|
|
25
|
-
textAlign: 'center',
|
|
26
|
-
padding: '20px',
|
|
27
|
-
fontFamily: 'Arial, sans-serif',
|
|
28
|
-
},
|
|
29
|
-
counter: {
|
|
30
|
-
fontSize: '2rem',
|
|
31
|
-
margin: '20px 0',
|
|
32
|
-
},
|
|
33
|
-
buttonContainer: {
|
|
34
|
-
display: 'flex',
|
|
35
|
-
justifyContent: 'center',
|
|
36
|
-
gap: '10px',
|
|
37
|
-
},
|
|
38
|
-
button: {
|
|
39
|
-
padding: '10px 20px',
|
|
40
|
-
fontSize: '1rem',
|
|
41
|
-
cursor: 'pointer',
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default Count;
|
|
46
|
-
`
|
|
47
|
-
return {
|
|
48
|
-
content,
|
|
49
|
-
filename: `${args.rootdir}/${args.entry}`
|
|
50
|
-
}
|
|
1
|
+
export default (args) => {
|
|
2
|
+
const content = `import React, { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
const Count: React.FC = () => {
|
|
5
|
+
const [count, setCount] = useState<number>(0);
|
|
6
|
+
const increment = (): void => setCount(prevCount => prevCount + 1);
|
|
7
|
+
const decrement = (): void => setCount(prevCount => prevCount - 1);
|
|
8
|
+
const reset = (): void => setCount(0);
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div style={styles.container}>
|
|
12
|
+
<h1>Count App</h1>
|
|
13
|
+
<div style={styles.counter}>{count}</div>
|
|
14
|
+
<div style={styles.buttonContainer}>
|
|
15
|
+
<button style={styles.button} onClick={increment}>Increment</button>
|
|
16
|
+
<button style={styles.button} onClick={decrement}>Decrement</button>
|
|
17
|
+
<button style={styles.button} onClick={reset}>Reset</button>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const styles: { [key: string]: React.CSSProperties } = {
|
|
24
|
+
container: {
|
|
25
|
+
textAlign: 'center',
|
|
26
|
+
padding: '20px',
|
|
27
|
+
fontFamily: 'Arial, sans-serif',
|
|
28
|
+
},
|
|
29
|
+
counter: {
|
|
30
|
+
fontSize: '2rem',
|
|
31
|
+
margin: '20px 0',
|
|
32
|
+
},
|
|
33
|
+
buttonContainer: {
|
|
34
|
+
display: 'flex',
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
gap: '10px',
|
|
37
|
+
},
|
|
38
|
+
button: {
|
|
39
|
+
padding: '10px 20px',
|
|
40
|
+
fontSize: '1rem',
|
|
41
|
+
cursor: 'pointer',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default Count;
|
|
46
|
+
`
|
|
47
|
+
return {
|
|
48
|
+
content,
|
|
49
|
+
filename: `${args.rootdir}/${args.entry}`
|
|
50
|
+
}
|
|
51
51
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import fs from 'fs-extra'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
4
|
-
export const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
5
|
-
|
|
6
|
-
export default (args) => {
|
|
7
|
-
// load readme.md content from rootdir
|
|
8
|
-
const readme = fs.readFileSync(path.resolve(__dirname, '../../../../readme.md'), 'utf-8')
|
|
9
|
-
const content = readme
|
|
10
|
-
return {
|
|
11
|
-
content,
|
|
12
|
-
filename: `readme.md`
|
|
13
|
-
}
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
export const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
5
|
+
|
|
6
|
+
export default (args) => {
|
|
7
|
+
// load readme.md content from rootdir
|
|
8
|
+
const readme = fs.readFileSync(path.resolve(__dirname, '../../../../readme.md'), 'utf-8')
|
|
9
|
+
const content = readme
|
|
10
|
+
return {
|
|
11
|
+
content,
|
|
12
|
+
filename: `readme.md`
|
|
13
|
+
}
|
|
14
14
|
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
export default args => {
|
|
2
|
-
let ext = args.template === 'react with typescript' ? ".tsx" : ".jsx"
|
|
3
|
-
let _import = ''
|
|
4
|
-
let _code = ''
|
|
5
|
-
|
|
6
|
-
switch (args.template) {
|
|
7
|
-
case "typescript":
|
|
8
|
-
case "javascript":
|
|
9
|
-
_import = `import add from './${args.rootdir}'`
|
|
10
|
-
_code = `<code>{add(5,5)}</code>`
|
|
11
|
-
break
|
|
12
|
-
case "react with typescript":
|
|
13
|
-
case "react with javascript":
|
|
14
|
-
_import = `import Count from './${args.rootdir}'`
|
|
15
|
-
_code = `<Count />`
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const content = `import React from 'react';
|
|
20
|
-
import { createRoot } from 'react-dom/client';
|
|
21
|
-
${_import}
|
|
22
|
-
|
|
23
|
-
const App = () => {
|
|
24
|
-
return (
|
|
25
|
-
<div style={{fontFamily: 'monospace,math, sans-serif', textAlign: 'center', marginTop: '50px' }}>
|
|
26
|
-
<h1>Welcome to makepack CLI!</h1>
|
|
27
|
-
<p>Edit <code>index.tsx</code> and save to reload.</p>
|
|
28
|
-
<a
|
|
29
|
-
href="https://reactjs.org"
|
|
30
|
-
target="_blank"
|
|
31
|
-
rel="noopener noreferrer"
|
|
32
|
-
style={{ color: '#61dafb', textDecoration: 'none' }}
|
|
33
|
-
>
|
|
34
|
-
Learn React
|
|
35
|
-
</a>
|
|
36
|
-
<div style={{marginTop: "50px"}}>
|
|
37
|
-
${_code}
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
const rootEle = document.getElementById('root')
|
|
43
|
-
if (rootEle) {
|
|
44
|
-
const root = createRoot(rootEle);
|
|
45
|
-
root.render(<App />);
|
|
46
|
-
}
|
|
47
|
-
`
|
|
48
|
-
return {
|
|
49
|
-
content,
|
|
50
|
-
filename: `serve${ext}`
|
|
51
|
-
}
|
|
1
|
+
export default args => {
|
|
2
|
+
let ext = args.template === 'react with typescript' ? ".tsx" : ".jsx"
|
|
3
|
+
let _import = ''
|
|
4
|
+
let _code = ''
|
|
5
|
+
|
|
6
|
+
switch (args.template) {
|
|
7
|
+
case "typescript":
|
|
8
|
+
case "javascript":
|
|
9
|
+
_import = `import add from './${args.rootdir}'`
|
|
10
|
+
_code = `<code>{add(5,5)}</code>`
|
|
11
|
+
break
|
|
12
|
+
case "react with typescript":
|
|
13
|
+
case "react with javascript":
|
|
14
|
+
_import = `import Count from './${args.rootdir}'`
|
|
15
|
+
_code = `<Count />`
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const content = `import React from 'react';
|
|
20
|
+
import { createRoot } from 'react-dom/client';
|
|
21
|
+
${_import}
|
|
22
|
+
|
|
23
|
+
const App = () => {
|
|
24
|
+
return (
|
|
25
|
+
<div style={{fontFamily: 'monospace,math, sans-serif', textAlign: 'center', marginTop: '50px' }}>
|
|
26
|
+
<h1>Welcome to makepack CLI!</h1>
|
|
27
|
+
<p>Edit <code>index.tsx</code> and save to reload.</p>
|
|
28
|
+
<a
|
|
29
|
+
href="https://reactjs.org"
|
|
30
|
+
target="_blank"
|
|
31
|
+
rel="noopener noreferrer"
|
|
32
|
+
style={{ color: '#61dafb', textDecoration: 'none' }}
|
|
33
|
+
>
|
|
34
|
+
Learn React
|
|
35
|
+
</a>
|
|
36
|
+
<div style={{marginTop: "50px"}}>
|
|
37
|
+
${_code}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const rootEle = document.getElementById('root')
|
|
43
|
+
if (rootEle) {
|
|
44
|
+
const root = createRoot(rootEle);
|
|
45
|
+
root.render(<App />);
|
|
46
|
+
}
|
|
47
|
+
`
|
|
48
|
+
return {
|
|
49
|
+
content,
|
|
50
|
+
filename: `serve${ext}`
|
|
51
|
+
}
|
|
52
52
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
export default args => {
|
|
2
|
-
const content = {
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"lib": [
|
|
6
|
-
"dom",
|
|
7
|
-
"dom.iterable",
|
|
8
|
-
"esnext"
|
|
9
|
-
],
|
|
10
|
-
"allowJs": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"allowSyntheticDefaultImports": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"module": "esnext",
|
|
17
|
-
"moduleResolution": "node",
|
|
18
|
-
"resolveJsonModule": true,
|
|
19
|
-
"isolatedModules": true,
|
|
20
|
-
"noEmit": true,
|
|
21
|
-
"jsx": "react"
|
|
22
|
-
},
|
|
23
|
-
"include": [args.rootdir],
|
|
24
|
-
"exclude": [
|
|
25
|
-
"node_modules"
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
content: JSON.stringify(content, null, 2),
|
|
31
|
-
filename: "tsconfig.json"
|
|
32
|
-
}
|
|
1
|
+
export default args => {
|
|
2
|
+
const content = {
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"lib": [
|
|
6
|
+
"dom",
|
|
7
|
+
"dom.iterable",
|
|
8
|
+
"esnext"
|
|
9
|
+
],
|
|
10
|
+
"allowJs": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"module": "esnext",
|
|
17
|
+
"moduleResolution": "node",
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"isolatedModules": true,
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"jsx": "react"
|
|
22
|
+
},
|
|
23
|
+
"include": [args.rootdir],
|
|
24
|
+
"exclude": [
|
|
25
|
+
"node_modules"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
content: JSON.stringify(content, null, 2),
|
|
31
|
+
filename: "tsconfig.json"
|
|
32
|
+
}
|
|
33
33
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { execSync, logLoader, logger } from "../../helpers.js"
|
|
2
|
-
import makeProjectInformation from "./makeProjectInformation.js"
|
|
3
|
-
import makeFiles from "./makeFiles.js"
|
|
4
|
-
import figlet from 'figlet'
|
|
5
|
-
|
|
6
|
-
const create = async () => {
|
|
7
|
-
let info = await makeProjectInformation()
|
|
8
|
-
logger.info("", "Creating project...", false)
|
|
9
|
-
await makeFiles(info)
|
|
10
|
-
|
|
11
|
-
logger.info("", "Installing Dependencies", false)
|
|
12
|
-
execSync("npm install", {
|
|
13
|
-
cwd: info.cwd,
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
logger.info("Project setup complete!", "", false)
|
|
17
|
-
if (info.isCurrentDir) {
|
|
18
|
-
console.log(`Run the development server: \n${logger.info("", "npm start", false)}\nEnjoy your new project! 😊`);
|
|
19
|
-
} else {
|
|
20
|
-
console.log(`To start working with your project:\nNavigate to your project directory:\n${logger.info("", "cd " + info.dirname, false)} and Run the development server:\n${logger.info("", "npm start", false)}\nEnjoy your new project! 😊`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
figlet("Make Pack CLI", function (err, data) {
|
|
24
|
-
if (!err) {
|
|
25
|
-
console.log(data);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
1
|
+
import { execSync, logLoader, logger } from "../../helpers.js"
|
|
2
|
+
import makeProjectInformation from "./makeProjectInformation.js"
|
|
3
|
+
import makeFiles from "./makeFiles.js"
|
|
4
|
+
import figlet from 'figlet'
|
|
5
|
+
|
|
6
|
+
const create = async () => {
|
|
7
|
+
let info = await makeProjectInformation()
|
|
8
|
+
logger.info("", "Creating project...", false)
|
|
9
|
+
await makeFiles(info)
|
|
10
|
+
|
|
11
|
+
logger.info("", "Installing Dependencies", false)
|
|
12
|
+
execSync("npm install", {
|
|
13
|
+
cwd: info.cwd,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
logger.info("Project setup complete!", "", false)
|
|
17
|
+
if (info.isCurrentDir) {
|
|
18
|
+
console.log(`Run the development server: \n${logger.info("", "npm start", false)}\nEnjoy your new project! 😊`);
|
|
19
|
+
} else {
|
|
20
|
+
console.log(`To start working with your project:\nNavigate to your project directory:\n${logger.info("", "cd " + info.dirname, false)} and Run the development server:\n${logger.info("", "npm start", false)}\nEnjoy your new project! 😊`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
figlet("Make Pack CLI", function (err, data) {
|
|
24
|
+
if (!err) {
|
|
25
|
+
console.log(data);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
30
|
export default create
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
// import makepack from "./files/makepack.js";
|
|
2
|
-
import packageJson from "./files/package-json.js";
|
|
3
|
-
import gitignore from "./files/gitignore.js";
|
|
4
|
-
import serve from "./files/serve.js";
|
|
5
|
-
import tsconfig from "./files/tsconfig.js";
|
|
6
|
-
import projectJs from "./files/project-js.js";
|
|
7
|
-
import projectJsx from "./files/project-jsx.js";
|
|
8
|
-
import projectTs from "./files/project-ts.js";
|
|
9
|
-
import projectTsx from "./files/project-tsx.js";
|
|
10
|
-
|
|
11
|
-
import inquirer from 'inquirer'
|
|
12
|
-
import fs from "fs-extra"
|
|
13
|
-
import path from "path"
|
|
14
|
-
import readmeMd from "./files/readme.md.js";
|
|
15
|
-
|
|
16
|
-
export default async (args) => {
|
|
17
|
-
const files = [
|
|
18
|
-
packageJson(args),
|
|
19
|
-
gitignore(args),
|
|
20
|
-
serve(args),
|
|
21
|
-
readmeMd(args)
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
switch (args.template) {
|
|
25
|
-
case "typescript":
|
|
26
|
-
files.push(projectTs(args))
|
|
27
|
-
break
|
|
28
|
-
case "react with typescript":
|
|
29
|
-
files.push(projectTsx(args))
|
|
30
|
-
break;
|
|
31
|
-
case "javascript":
|
|
32
|
-
files.push(projectJs(args))
|
|
33
|
-
break
|
|
34
|
-
case "react with javascript":
|
|
35
|
-
files.push(projectJsx(args))
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// push ts config
|
|
40
|
-
if (args.template.includes("typescript")) {
|
|
41
|
-
files.push(tsconfig(args))
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
for (let file of files) {
|
|
45
|
-
// check if the file exists
|
|
46
|
-
if (fs.existsSync(path.join(args.cwd, file.filename))) {
|
|
47
|
-
const { overwrite } = await inquirer.prompt([
|
|
48
|
-
{
|
|
49
|
-
type: "confirm",
|
|
50
|
-
name: 'overwrite',
|
|
51
|
-
message: `The file ${file.filename} already exists, do you want to overwrite it?`,
|
|
52
|
-
default: true
|
|
53
|
-
}
|
|
54
|
-
])
|
|
55
|
-
if (!overwrite) {
|
|
56
|
-
continue
|
|
57
|
-
} else {
|
|
58
|
-
fs.removeSync(path.join(args.cwd, file.filename))
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
fs.writeFileSync(path.join(args.cwd, file.filename), file.content)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
// import makepack from "./files/makepack.js";
|
|
2
|
+
import packageJson from "./files/package-json.js";
|
|
3
|
+
import gitignore from "./files/gitignore.js";
|
|
4
|
+
import serve from "./files/serve.js";
|
|
5
|
+
import tsconfig from "./files/tsconfig.js";
|
|
6
|
+
import projectJs from "./files/project-js.js";
|
|
7
|
+
import projectJsx from "./files/project-jsx.js";
|
|
8
|
+
import projectTs from "./files/project-ts.js";
|
|
9
|
+
import projectTsx from "./files/project-tsx.js";
|
|
10
|
+
|
|
11
|
+
import inquirer from 'inquirer'
|
|
12
|
+
import fs from "fs-extra"
|
|
13
|
+
import path from "path"
|
|
14
|
+
import readmeMd from "./files/readme.md.js";
|
|
15
|
+
|
|
16
|
+
export default async (args) => {
|
|
17
|
+
const files = [
|
|
18
|
+
packageJson(args),
|
|
19
|
+
gitignore(args),
|
|
20
|
+
serve(args),
|
|
21
|
+
readmeMd(args)
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
switch (args.template) {
|
|
25
|
+
case "typescript":
|
|
26
|
+
files.push(projectTs(args))
|
|
27
|
+
break
|
|
28
|
+
case "react with typescript":
|
|
29
|
+
files.push(projectTsx(args))
|
|
30
|
+
break;
|
|
31
|
+
case "javascript":
|
|
32
|
+
files.push(projectJs(args))
|
|
33
|
+
break
|
|
34
|
+
case "react with javascript":
|
|
35
|
+
files.push(projectJsx(args))
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// push ts config
|
|
40
|
+
if (args.template.includes("typescript")) {
|
|
41
|
+
files.push(tsconfig(args))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (let file of files) {
|
|
45
|
+
// check if the file exists
|
|
46
|
+
if (fs.existsSync(path.join(args.cwd, file.filename))) {
|
|
47
|
+
const { overwrite } = await inquirer.prompt([
|
|
48
|
+
{
|
|
49
|
+
type: "confirm",
|
|
50
|
+
name: 'overwrite',
|
|
51
|
+
message: `The file ${file.filename} already exists, do you want to overwrite it?`,
|
|
52
|
+
default: true
|
|
53
|
+
}
|
|
54
|
+
])
|
|
55
|
+
if (!overwrite) {
|
|
56
|
+
continue
|
|
57
|
+
} else {
|
|
58
|
+
fs.removeSync(path.join(args.cwd, file.filename))
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fs.writeFileSync(path.join(args.cwd, file.filename), file.content)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import path from "path"
|
|
2
|
-
import fs from "fs-extra"
|
|
3
|
-
import inquirer from "inquirer"
|
|
4
|
-
const cwd = process.cwd()
|
|
5
|
-
const cwdFolder = cwd.split(path.sep).pop()
|
|
6
|
-
|
|
7
|
-
export default async () => {
|
|
8
|
-
const { projectDirName } = await inquirer.prompt([
|
|
9
|
-
{
|
|
10
|
-
type: 'input',
|
|
11
|
-
name: 'projectDirName',
|
|
12
|
-
message: 'Enter the project name',
|
|
13
|
-
default: cwdFolder
|
|
14
|
-
}
|
|
15
|
-
])
|
|
16
|
-
|
|
17
|
-
let projectDir = cwd
|
|
18
|
-
|
|
19
|
-
if (projectDirName !== cwdFolder) {
|
|
20
|
-
projectDir = path.join(cwd, projectDirName);
|
|
21
|
-
if (fs.existsSync(projectDir)) {
|
|
22
|
-
const { proceed } = await inquirer.prompt([
|
|
23
|
-
{
|
|
24
|
-
type: "confirm",
|
|
25
|
-
name: 'proceed',
|
|
26
|
-
message: "The directory already exists, do you want to overwrite it?",
|
|
27
|
-
default: cwdFolder
|
|
28
|
-
}
|
|
29
|
-
])
|
|
30
|
-
if (!proceed) {
|
|
31
|
-
console.log('Project creation canceled.');
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
cwd: projectDir,
|
|
39
|
-
dirname: projectDirName,
|
|
40
|
-
isCurrentDir: projectDirName === cwdFolder
|
|
41
|
-
}
|
|
1
|
+
import path from "path"
|
|
2
|
+
import fs from "fs-extra"
|
|
3
|
+
import inquirer from "inquirer"
|
|
4
|
+
const cwd = process.cwd()
|
|
5
|
+
const cwdFolder = cwd.split(path.sep).pop()
|
|
6
|
+
|
|
7
|
+
export default async () => {
|
|
8
|
+
const { projectDirName } = await inquirer.prompt([
|
|
9
|
+
{
|
|
10
|
+
type: 'input',
|
|
11
|
+
name: 'projectDirName',
|
|
12
|
+
message: 'Enter the project name',
|
|
13
|
+
default: cwdFolder
|
|
14
|
+
}
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
let projectDir = cwd
|
|
18
|
+
|
|
19
|
+
if (projectDirName !== cwdFolder) {
|
|
20
|
+
projectDir = path.join(cwd, projectDirName);
|
|
21
|
+
if (fs.existsSync(projectDir)) {
|
|
22
|
+
const { proceed } = await inquirer.prompt([
|
|
23
|
+
{
|
|
24
|
+
type: "confirm",
|
|
25
|
+
name: 'proceed',
|
|
26
|
+
message: "The directory already exists, do you want to overwrite it?",
|
|
27
|
+
default: cwdFolder
|
|
28
|
+
}
|
|
29
|
+
])
|
|
30
|
+
if (!proceed) {
|
|
31
|
+
console.log('Project creation canceled.');
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
cwd: projectDir,
|
|
39
|
+
dirname: projectDirName,
|
|
40
|
+
isCurrentDir: projectDirName === cwdFolder
|
|
41
|
+
}
|
|
42
42
|
}
|