makepack 1.4.0 → 1.5.1
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 +122 -167
- package/package.json +58 -56
- package/src/actions/build/index.js +91 -0
- package/src/actions/create/files/{serve.js → App.js} +51 -51
- package/src/actions/create/files/config.js +55 -0
- package/src/actions/create/files/gitignore.js +8 -5
- package/src/actions/create/files/package-json.js +54 -59
- 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/tsconfig.js +32 -32
- package/src/actions/create/index.js +108 -29
- package/src/actions/create/makeFiles.js +64 -64
- package/src/actions/publish/index.js +19 -0
- package/src/actions/{serve → start}/index.js +92 -97
- package/src/helpers.js +37 -122
- package/src/index.js +33 -30
- package/src/makepack-config.js +66 -0
- package/src/actions/create/files/makepack.js +0 -19
- package/src/actions/create/makeProjectDirectory.js +0 -42
- package/src/actions/create/makeProjectInformation.js +0 -68
- package/src/actions/pack/index.js +0 -112
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import makepackConfig from "../../../makepack-config.js"
|
|
2
|
+
|
|
3
|
+
export default async () => {
|
|
4
|
+
const config = await makepackConfig()
|
|
5
|
+
return {
|
|
6
|
+
content: `node_modules\n${config.build.outdir}`,
|
|
7
|
+
filename: ".gitignore"
|
|
8
|
+
}
|
|
6
9
|
}
|
|
@@ -1,60 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
devDependencies["
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
description: "",
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
content: JSON.stringify(json, null, 3),
|
|
58
|
-
filename: "package.json"
|
|
59
|
-
}
|
|
1
|
+
|
|
2
|
+
export default async (info) => {
|
|
3
|
+
let dependencies = {}
|
|
4
|
+
let devDependencies = {
|
|
5
|
+
"makepack": "latest",
|
|
6
|
+
"react": "^19.0.0",
|
|
7
|
+
"react-dom": "^19.0.0",
|
|
8
|
+
"express": "latest"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (info.template.includes("typescript")) {
|
|
12
|
+
devDependencies["typescript"] = "^4.4.2"
|
|
13
|
+
devDependencies["@types/react"] = "^19.0.2"
|
|
14
|
+
devDependencies["@types/react-dom"] = "^19.0.2"
|
|
15
|
+
devDependencies["@types/express"] = "latest"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let main = info.sourceEntry.split('.')
|
|
19
|
+
main.pop()
|
|
20
|
+
|
|
21
|
+
const json = {
|
|
22
|
+
name: info.projectDirName,
|
|
23
|
+
version: "1.0.0",
|
|
24
|
+
main: `./index.js`,
|
|
25
|
+
module: `./esm/index.js`,
|
|
26
|
+
types: `./types/index.d.ts`,
|
|
27
|
+
description: "",
|
|
28
|
+
keywords: [],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./types/index.d.ts",
|
|
32
|
+
"require": "./cjs/index.js",
|
|
33
|
+
"import": "./index.js",
|
|
34
|
+
},
|
|
35
|
+
"./types/*": "./types/*.d.ts",
|
|
36
|
+
"./cjs/*": "./cjs/*.js",
|
|
37
|
+
"./*": {
|
|
38
|
+
"import": "./*.js",
|
|
39
|
+
"require": "./cjs/*.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
scripts: {
|
|
43
|
+
"start": "makepack serve",
|
|
44
|
+
"build": "makepack build",
|
|
45
|
+
"build:publish": "makepack publish"
|
|
46
|
+
},
|
|
47
|
+
dependencies,
|
|
48
|
+
devDependencies
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
content: JSON.stringify(json, null, 3),
|
|
53
|
+
filename: "package.json"
|
|
54
|
+
}
|
|
60
55
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export default (args) => {
|
|
2
|
-
const content = `
|
|
3
|
-
function add(a, b) {
|
|
4
|
-
return a + b;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default add
|
|
8
|
-
`
|
|
9
|
-
return {
|
|
10
|
-
content,
|
|
11
|
-
filename: `${args.
|
|
12
|
-
}
|
|
1
|
+
export default async (args) => {
|
|
2
|
+
const content = `
|
|
3
|
+
function add(a, b) {
|
|
4
|
+
return a + b;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default add
|
|
8
|
+
`
|
|
9
|
+
return {
|
|
10
|
+
content,
|
|
11
|
+
filename: `${args.sourceDir}/${args.sourceEntry}`
|
|
12
|
+
}
|
|
13
13
|
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
export default (args) => {
|
|
2
|
-
const content = `import React, { useState } from 'react';
|
|
3
|
-
|
|
4
|
-
const Count = () => {
|
|
5
|
-
const [count, setCount] = useState(0);
|
|
6
|
-
const increment = () => setCount(prevCount => prevCount + 1);
|
|
7
|
-
const decrement = () => setCount(prevCount => prevCount - 1);
|
|
8
|
-
const reset = () => 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 = {
|
|
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.
|
|
50
|
-
}
|
|
1
|
+
export default async (args) => {
|
|
2
|
+
const content = `import React, { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
const Count = () => {
|
|
5
|
+
const [count, setCount] = useState(0);
|
|
6
|
+
const increment = () => setCount(prevCount => prevCount + 1);
|
|
7
|
+
const decrement = () => setCount(prevCount => prevCount - 1);
|
|
8
|
+
const reset = () => 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 = {
|
|
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.sourceDir}/${args.sourceEntry}`
|
|
50
|
+
}
|
|
51
51
|
}
|
|
@@ -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.
|
|
10
|
-
}
|
|
1
|
+
export default async (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.sourceDir}/${args.sourceEntry}`
|
|
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.
|
|
50
|
-
}
|
|
1
|
+
export default async (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.sourceDir}/${args.sourceEntry}`
|
|
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 (
|
|
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 async () => {
|
|
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,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 async (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,109 @@
|
|
|
1
|
-
import { execSync,
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
cwd:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { execSync, logger } from "../../helpers.js"
|
|
2
|
+
import makeFiles from "./makeFiles.js"
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
|
+
import figlet from 'figlet'
|
|
6
|
+
import fs from "fs-extra"
|
|
7
|
+
const cwd = process.cwd()
|
|
8
|
+
const cwdFolder = cwd.split(path.sep).pop()
|
|
9
|
+
|
|
10
|
+
const create = async () => {
|
|
11
|
+
const information = {
|
|
12
|
+
projectDirName: cwdFolder,
|
|
13
|
+
cwd: path.join(cwd, cwdFolder),
|
|
14
|
+
template: "typescript",
|
|
15
|
+
sourceDir: "src",
|
|
16
|
+
sourceEntry: "index.ts",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let { projectDirName } = await inquirer.prompt([
|
|
20
|
+
{
|
|
21
|
+
type: 'input',
|
|
22
|
+
name: 'projectDirName',
|
|
23
|
+
message: 'Enter the project name',
|
|
24
|
+
default: information.projectDir
|
|
25
|
+
}
|
|
26
|
+
])
|
|
27
|
+
|
|
28
|
+
if (projectDirName !== cwdFolder) {
|
|
29
|
+
if (fs.existsSync(path.join(cwd, projectDirName))) {
|
|
30
|
+
const { proceed } = await inquirer.prompt([
|
|
31
|
+
{
|
|
32
|
+
type: "confirm",
|
|
33
|
+
name: 'proceed',
|
|
34
|
+
message: "The directory already exists, do you want to overwrite it?",
|
|
35
|
+
default: "No"
|
|
36
|
+
}
|
|
37
|
+
])
|
|
38
|
+
if (!proceed) {
|
|
39
|
+
console.log('Project creation canceled.');
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
information.projectDirName = projectDirName
|
|
46
|
+
information.cwd = path.join(cwd, information.projectDirName)
|
|
47
|
+
let isCurrentDir = projectDirName !== cwdFolder
|
|
48
|
+
|
|
49
|
+
// template
|
|
50
|
+
const { template } = await inquirer.prompt([
|
|
51
|
+
{
|
|
52
|
+
type: 'list',
|
|
53
|
+
name: 'template',
|
|
54
|
+
message: 'Select a template',
|
|
55
|
+
choices: ['typescript', 'javascript', 'react with typescript', 'react with javascript'],
|
|
56
|
+
default: information.template
|
|
57
|
+
}
|
|
58
|
+
])
|
|
59
|
+
|
|
60
|
+
information.template = template
|
|
61
|
+
|
|
62
|
+
logger.info("", "Creating project...", false)
|
|
63
|
+
const projectDir = path.join(cwd, information.projectDirName)
|
|
64
|
+
|
|
65
|
+
if (information.projectDirName !== cwdFolder) {
|
|
66
|
+
if (fs.existsSync(projectDir)) {
|
|
67
|
+
fs.removeSync(projectDir)
|
|
68
|
+
}
|
|
69
|
+
fs.mkdirSync(projectDir)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!fs.existsSync(path.join(projectDir, information.sourceDir))) {
|
|
73
|
+
fs.mkdirSync(path.join(projectDir, information.sourceDir))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
switch (information.template) {
|
|
77
|
+
case "react with typescript":
|
|
78
|
+
information.sourceEntry = "index.tsx"
|
|
79
|
+
break;
|
|
80
|
+
case "react with javascript":
|
|
81
|
+
information.sourceEntry = "index.jsx"
|
|
82
|
+
break;
|
|
83
|
+
case "javascript":
|
|
84
|
+
information.sourceEntry = "index.js"
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
await makeFiles(information)
|
|
89
|
+
|
|
90
|
+
logger.info("", "Installing Dependencies", false)
|
|
91
|
+
execSync("npm install", {
|
|
92
|
+
cwd: information.cwd,
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
logger.info("Project setup complete!", "", false)
|
|
96
|
+
if (isCurrentDir) {
|
|
97
|
+
console.log(`Run the development server: \n${logger.info("", "npm start", false)}\nEnjoy your new project! 😊`);
|
|
98
|
+
} else {
|
|
99
|
+
console.log(`To start working with your project:\nNavigate to your project directory:\n${logger.info("", "cd " + information.projectDirName, false)} and Run the development server:\n${logger.info("", "npm start", false)}\nEnjoy your new project! 😊`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
figlet("Makepack CLI", function (err, data) {
|
|
103
|
+
if (!err) {
|
|
104
|
+
console.log(data);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
30
109
|
export default create
|