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.
@@ -1,6 +1,9 @@
1
- export default (args) => {
2
- return {
3
- content: `node_modules\n${args.outdir}`,
4
- filename: ".gitignore"
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
- export default (args) => {
2
- let dependencies = {}
3
- let devDependencies = {
4
- "makepack": "latest"
5
- }
6
-
7
- if (args.template.includes("react")) {
8
- dependencies["react"] = "^19.0.0"
9
- dependencies["react-dom"] = "^19.0.0"
10
- } else {
11
- devDependencies["react"] = "^19.0.0"
12
- devDependencies["react-dom"] = "^19.0.0"
13
- }
14
-
15
- if (args.template.includes("typescript")) {
16
- devDependencies["typescript"] = "^4.4.2"
17
- devDependencies["@types/react"] = "^19.0.2"
18
- devDependencies["@types/react-dom"] = "^19.0.2"
19
- }
20
-
21
- let main = args.entry.split('.')
22
- main.pop()
23
-
24
- const json = {
25
- name: args.dirname,
26
- version: "1.0.0",
27
- description: "",
28
- main: `./${main.join(".")}.js`,
29
- scripts: {
30
- "start": "makepack serve",
31
- "pack": "makepack pack",
32
- "publish:pack": "makepack pack -p",
33
- },
34
- dependencies,
35
- devDependencies,
36
- keywords: [],
37
- exports: {
38
- ".": {
39
- "types": "./types/index.d.ts",
40
- "import": "./esm/index.js",
41
- "require": "./cjs/index.js"
42
- },
43
- "./*": {
44
- "types": "./types/*.d.ts",
45
- "import": "./esm/*.js",
46
- "require": "./cjs/*.js"
47
- },
48
- "./types/*": "./types/*.d.ts",
49
- "./esm/*": "./esm/*.js",
50
- "./esm/*.js": "./esm/*.js",
51
- "./cjs/*": "./cjs/*.js",
52
- "./cjs/*.js": "./cjs/*.js"
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.rootdir}/${args.entry}`
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.rootdir}/${args.entry}`
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.rootdir}/${args.entry}`
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.rootdir}/${args.entry}`
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 (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 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, 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, 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