makepack 1.6.2 → 1.6.4

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.6.2",
3
+ "version": "1.6.4",
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
  "files": [
@@ -148,6 +148,9 @@ const build = async (args) => {
148
148
  pkgjson.types = `./index.d.ts`;
149
149
  }
150
150
 
151
+ delete pkgjson.scripts
152
+ delete pkgjson.type
153
+
151
154
  fs.writeFileSync(path.join(outdir, 'package.json'), JSON.stringify(pkgjson, null, 2));
152
155
  } else {
153
156
  spinner.fail("package.json not found!");
@@ -0,0 +1,37 @@
1
+ export default async ({ template }) => {
2
+
3
+ let ext = 'jsx'
4
+ if (template === 'react with typescript') {
5
+ ext = 'tsx'
6
+ } else if (template === 'typescript') {
7
+ ext = 'ts'
8
+ }
9
+ else if (template === 'javascript') {
10
+ ext = 'js'
11
+ }
12
+
13
+ const content = `import React from 'react';
14
+ import { createRoot } from 'react-dom/client';
15
+ import ${ext.includes("sx") ? "Count" : "sum"} from './src/index.${ext}';
16
+
17
+ const Main = () => {
18
+ return (
19
+ <div>
20
+ <h1>Welcome to makepack CLI!</h1>
21
+ <p>Edit <code>index.${ext}</code> and save to reload.</p>
22
+ ${ext.includes("sx") ? "<Count />" : "<p>The sum is: {sum(5, 5)}</p>"}
23
+ </div>
24
+ );
25
+ };
26
+
27
+ const rootEle = document.getElementById('root')
28
+ if (rootEle) {
29
+ const root = createRoot(rootEle);
30
+ root.render(<Main />);
31
+ }
32
+ `
33
+ return {
34
+ content,
35
+ filename: `main.${ext.includes('ts') ? "tsx" : 'jsx'}`
36
+ }
37
+ }
@@ -7,8 +7,8 @@ export default async (info) => {
7
7
  }
8
8
 
9
9
  if (info.template.includes("react")) {
10
- dependencies["react"] = "^19.0.0"
11
- dependencies["react-dom"] = "^19.0.0"
10
+ devDependencies["react"] = "^19.0.0"
11
+ devDependencies["react-dom"] = "^19.0.0"
12
12
  }
13
13
 
14
14
  if (info.template.includes("typescript")) {
@@ -43,7 +43,7 @@ export default async (info) => {
43
43
  scripts: {
44
44
  "start": "makepack start",
45
45
  "build": "makepack build",
46
- "publish": "makepack publish"
46
+ "release": "makepack release"
47
47
  },
48
48
  dependencies,
49
49
  devDependencies
@@ -1,10 +1,10 @@
1
1
  export default async () => {
2
2
  const content = `
3
- function add(a, b) {
3
+ function sum(a, b) {
4
4
  return a + b;
5
5
  }
6
6
 
7
- export default add
7
+ export default sum
8
8
  `
9
9
  return {
10
10
  content,
@@ -1,8 +1,7 @@
1
1
  export default async () => {
2
2
  const content = `import React, { useState } from 'react';
3
- import { createRoot } from 'react-dom/client';
4
3
 
5
- const App = () => {
4
+ const Index = () => {
6
5
  const [count, setCount] = useState(0);
7
6
  const increment = () => setCount(prevCount => prevCount + 1);
8
7
  const decrement = () => setCount(prevCount => prevCount - 1);
@@ -43,11 +42,7 @@ const styles = {
43
42
  },
44
43
  };
45
44
 
46
- const rootEle = document.getElementById('root')
47
- if (rootEle) {
48
- const root = createRoot(rootEle);
49
- root.render(<App />);
50
- }
45
+ export default Index;
51
46
  `
52
47
  return {
53
48
  content,
@@ -1,9 +1,9 @@
1
1
  export default async () => {
2
2
  const content = `
3
- function add(a: number, b: number): number {
3
+ function sum(a: number, b: number): number {
4
4
  return a + b;
5
5
  }
6
- export default add`
6
+ export default sum`
7
7
  return {
8
8
  content,
9
9
  filename: `src/index.ts`
@@ -1,8 +1,7 @@
1
1
  export default async () => {
2
2
  const content = `import React, { useState } from 'react';
3
- import { createRoot } from 'react-dom/client';
4
3
 
5
- const App: React.FC = () => {
4
+ const Index: React.FC = () => {
6
5
  const [count, setCount] = useState<number>(0);
7
6
  const increment = (): void => setCount(prevCount => prevCount + 1);
8
7
  const decrement = (): void => setCount(prevCount => prevCount - 1);
@@ -43,11 +42,7 @@ const styles: { [key: string]: React.CSSProperties } = {
43
42
  },
44
43
  };
45
44
 
46
- const rootEle = document.getElementById('root')
47
- if (rootEle) {
48
- const root = createRoot(rootEle);
49
- root.render(<App />);
50
- }
45
+ export default Index;
51
46
  `
52
47
  return {
53
48
  content,
@@ -6,7 +6,7 @@ import projectJs from "./files/project-js.js";
6
6
  import projectJsx from "./files/project-jsx.js";
7
7
  import projectTs from "./files/project-ts.js";
8
8
  import projectTsx from "./files/project-tsx.js";
9
-
9
+ import mainjs from "./files/main.js";
10
10
  import inquirer from 'inquirer'
11
11
  import fs from "fs-extra"
12
12
  import path from "path"
@@ -16,7 +16,8 @@ export default async (info) => {
16
16
  const files = [
17
17
  await packageJson(info),
18
18
  await gitignore(info),
19
- await readmeMd(info)
19
+ await readmeMd(info),
20
+ await mainjs(info),
20
21
  ];
21
22
 
22
23
  switch (info.template) {
@@ -2,7 +2,7 @@ import path from 'path'
2
2
  import { execSync, logger } from '../../helpers.js'
3
3
  import fs from 'fs-extra'
4
4
 
5
- const publish = async () => {
5
+ const release = async () => {
6
6
  const buildDir = path.join(process.cwd(), '.mpack')
7
7
  const packageJsonPath = path.join(buildDir, 'package.json')
8
8
  const exists = fs.existsSync(buildDir)
@@ -11,10 +11,10 @@ const publish = async () => {
11
11
  process.exit(1)
12
12
  }
13
13
 
14
- logger.info(`Publishing the production build to the npm repository...`)
14
+ logger.info(`Releaseing the production build to the npm repository...`)
15
15
  execSync(`npm publish`, {
16
16
  cwd: buildDir
17
17
  })
18
18
  }
19
19
 
20
- export default publish
20
+ export default release
@@ -26,9 +26,8 @@ const viteSetup = async (app) => {
26
26
  app.use(vite.middlewares);
27
27
 
28
28
  // exists tsconfig.json in the root directory
29
- const isTs = fs.existsSync(path.resolve(process.cwd(), 'tsconfig.json'))
30
-
31
- let entry = isTs ? '/src/index.ts' : '/src/index.js';
29
+ const isTs = fs.existsSync(path.resolve(process.cwd(), 'main.tsx'))
30
+ let entry = `/main.${isTs ? "tsx" : "jsx"}`
32
31
 
33
32
  app.get('*', async (req, res, next) => {
34
33
  const url = req.originalUrl;
package/src/index.js CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  import start from "./actions/start/index.js";
5
5
  import build from "./actions/build/index.js";
6
6
  import create from "./actions/create/index.js";
7
- import publish from "./actions/publish/index.js";
7
+ import release from "./actions/release/index.js";
8
8
 
9
9
  const program = new Command();
10
10
 
@@ -34,8 +34,8 @@ program
34
34
  .action(build);
35
35
 
36
36
  program
37
- .command("publish")
38
- .description("Publish it to the npm repository")
39
- .action(publish);
37
+ .command("release")
38
+ .description("Release it to the npm repository")
39
+ .action(release);
40
40
 
41
41
  program.parse();