makepack 1.0.6 → 1.0.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/package.json +1 -1
- package/src/actions/create/files/project-js.js +1 -1
- package/src/actions/create/files/project-jsx.js +51 -0
- package/src/actions/create/files/project-ts.js +1 -1
- package/src/actions/create/files/project-tsx.js +51 -0
- package/src/actions/create/files/serve.js +18 -3
- package/src/actions/create/index.js +2 -2
- package/src/actions/create/makeFiles.js +8 -2
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +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.rootdir}/${args.entry}`
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
51
|
+
}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
export default args => {
|
|
2
|
-
let ext = ".jsx"
|
|
2
|
+
let ext = args.template === 'react with typescript' ? ".tsx" : ".jsx"
|
|
3
|
+
let _import = ''
|
|
4
|
+
let _code = ''
|
|
5
|
+
|
|
3
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
|
|
4
12
|
case "react with typescript":
|
|
5
|
-
|
|
13
|
+
case "react with javascript":
|
|
14
|
+
_import = `import Count from './${args.rootdir}'`
|
|
15
|
+
_code = `<Count />`
|
|
16
|
+
break;
|
|
6
17
|
}
|
|
7
18
|
|
|
8
19
|
const content = `import React from 'react';
|
|
9
20
|
import { createRoot } from 'react-dom/client';
|
|
21
|
+
${_import}
|
|
10
22
|
|
|
11
23
|
const App = () => {
|
|
12
24
|
return (
|
|
13
|
-
<div style={{fontFamily: '
|
|
25
|
+
<div style={{fontFamily: 'monospace,math, sans-serif', textAlign: 'center', marginTop: '50px' }}>
|
|
14
26
|
<h1>Welcome to makepack CLI!</h1>
|
|
15
27
|
<p>Edit <code>index.tsx</code> and save to reload.</p>
|
|
16
28
|
<a
|
|
@@ -21,6 +33,9 @@ const App = () => {
|
|
|
21
33
|
>
|
|
22
34
|
Learn React
|
|
23
35
|
</a>
|
|
36
|
+
<div style={{marginTop: "50px"}}>
|
|
37
|
+
${_code}
|
|
38
|
+
</div>
|
|
24
39
|
</div>
|
|
25
40
|
);
|
|
26
41
|
}
|
|
@@ -15,9 +15,9 @@ const create = async () => {
|
|
|
15
15
|
|
|
16
16
|
loader.stop("Project setup complete!")
|
|
17
17
|
if (projectInformation.isCurrentDir) {
|
|
18
|
-
console.log(`Run the development server: \
|
|
18
|
+
console.log(`Run the development server: \nnpm start\nEnjoy your new project! 😊`);
|
|
19
19
|
} else {
|
|
20
|
-
console.log(`To start working with your project:\n1. Navigate to your project directory:\ncd ${projectInformation.dirname}\n2. Run the development server:\
|
|
20
|
+
console.log(`To start working with your project:\n1. Navigate to your project directory:\ncd ${projectInformation.dirname}\n2. Run the development server:\nnpm start\nEnjoy your new project! 😊`);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
|
|
@@ -4,7 +4,9 @@ import gitignore from "./files/gitignore.js";
|
|
|
4
4
|
import serve from "./files/serve.js";
|
|
5
5
|
import tsconfig from "./files/tsconfig.js";
|
|
6
6
|
import projectJs from "./files/project-js.js";
|
|
7
|
+
import projectJsx from "./files/project-jsx.js";
|
|
7
8
|
import projectTs from "./files/project-ts.js";
|
|
9
|
+
import projectTsx from "./files/project-tsx.js";
|
|
8
10
|
|
|
9
11
|
import fs from "fs-extra"
|
|
10
12
|
import path from "path"
|
|
@@ -18,12 +20,16 @@ export default async (args) => {
|
|
|
18
20
|
|
|
19
21
|
switch (args.template) {
|
|
20
22
|
case "typescript":
|
|
21
|
-
case "react with typescript":
|
|
22
23
|
files.push(projectTs(args))
|
|
24
|
+
break
|
|
25
|
+
case "react with typescript":
|
|
26
|
+
files.push(projectTsx(args))
|
|
23
27
|
break;
|
|
24
28
|
case "javascript":
|
|
25
|
-
case "react with javascript":
|
|
26
29
|
files.push(projectJs(args))
|
|
30
|
+
break
|
|
31
|
+
case "react with javascript":
|
|
32
|
+
files.push(projectJsx(args))
|
|
27
33
|
break;
|
|
28
34
|
}
|
|
29
35
|
|
package/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@ program
|
|
|
18
18
|
program
|
|
19
19
|
.command("serve")
|
|
20
20
|
.option("-p, --port <number>", "Port number", "5000")
|
|
21
|
-
.option("-r, --root <file>", "root file"
|
|
21
|
+
.option("-r, --root <file>", "root file")
|
|
22
22
|
.description("Start the server")
|
|
23
23
|
.action(serve);
|
|
24
24
|
|