makepack 1.0.7 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makepack",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
6
6
  "categories": [
@@ -4,7 +4,7 @@ function add(a, b) {
4
4
  return a + b;
5
5
  }
6
6
 
7
- console.log(add(5, 3));
7
+ export default add
8
8
  `
9
9
  return {
10
10
  content,
@@ -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
+ }
@@ -3,7 +3,7 @@ export default args => {
3
3
  function add(a: number, b: number): number {
4
4
  return a + b;
5
5
  }
6
- console.log(add(5, 3));`
6
+ export default add`
7
7
  return {
8
8
  content,
9
9
  filename: `${args.rootdir}/${args.entry}`
@@ -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,12 +1,24 @@
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
- ext = ".tsx"
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 (
@@ -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: \n makepack serve\nEnjoy your new project! 😊`);
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:\nmakepack serve\nEnjoy your new project! 😊`);
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