makepack 1.3.6 → 1.3.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/README.md +146 -146
- package/package.json +56 -56
- package/src/actions/create/files/gitignore.js +5 -5
- package/src/actions/create/files/makepack.js +19 -19
- package/src/actions/create/files/package-json.js +42 -42
- 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/serve.js +51 -51
- package/src/actions/create/files/tsconfig.js +32 -32
- package/src/actions/create/index.js +29 -29
- package/src/actions/create/makeFiles.js +64 -64
- package/src/actions/create/makeProjectDirectory.js +41 -41
- package/src/actions/create/makeProjectInformation.js +67 -67
- package/src/actions/pack/index.js +94 -112
- package/src/actions/serve/index.js +96 -106
- package/src/helpers.js +121 -69
- package/src/index.js +30 -30
package/src/helpers.js
CHANGED
|
@@ -1,70 +1,122 @@
|
|
|
1
|
-
import child_process from 'child_process'
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import figures from 'figures';
|
|
4
|
-
import { pathToFileURL } from 'url';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import fs from 'fs-extra';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
import child_process from 'child_process'
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import figures from 'figures';
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import react from '@vitejs/plugin-react'
|
|
8
|
+
import ts from 'typescript'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export const logLoader = (message = "") => {
|
|
12
|
+
const spinner = ['|', '/', '-', '\\'];
|
|
13
|
+
let i = 0;
|
|
14
|
+
const interval = setInterval(() => {
|
|
15
|
+
process.stdout.write(`\r${message} ${spinner[i]}`);
|
|
16
|
+
i = (i + 1) % spinner.length;
|
|
17
|
+
}, 100);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
stop: (msg) => {
|
|
21
|
+
clearInterval(interval);
|
|
22
|
+
!!msg && console.log(`\r${msg}`);
|
|
23
|
+
process.stdout.write(`\r`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const execSync = (command, option = {}) => {
|
|
29
|
+
try {
|
|
30
|
+
const result = child_process.execSync(command, {
|
|
31
|
+
encoding: "utf-8",
|
|
32
|
+
stdio: 'inherit',
|
|
33
|
+
...option
|
|
34
|
+
});
|
|
35
|
+
result && console.log(result);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(`Command failed: ${error.message}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export const logger = {
|
|
45
|
+
info: (message, prefix = 'INFO', icon = true) => {
|
|
46
|
+
console.log(`${icon ? chalk.blue(figures.info) + " " : ""}${chalk.cyan.bold(prefix)} ${message}`);
|
|
47
|
+
},
|
|
48
|
+
success: (message, prefix = 'SUCCESS:', icon = true) => {
|
|
49
|
+
console.log(`${icon ? chalk.green(figures.tick) + " " : ""}${chalk.green.bold(prefix)} ${message}`);
|
|
50
|
+
},
|
|
51
|
+
warning: (message, prefix = 'WARNING:', icon = true) => {
|
|
52
|
+
console.log(`${icon ? chalk.yellow(figures.warning) + " " : ""}${chalk.yellow.bold(prefix)} ${message}`);
|
|
53
|
+
},
|
|
54
|
+
error: (message, prefix = 'ERROR:', icon = true) => {
|
|
55
|
+
console.log(`${icon ? chalk.red(figures.cross) + " " : ""}${chalk.red.bold(prefix)} ${message}`);
|
|
56
|
+
},
|
|
57
|
+
custom: (icon, color, label, message) => {
|
|
58
|
+
console.log(`${chalk[color](icon)} ${chalk[color].bold(`${label}:`)} ${message}`);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export const loadConfig = async (args) => {
|
|
64
|
+
const makepack = path.resolve(process.cwd(), "makepack.js");
|
|
65
|
+
let esbuild = {
|
|
66
|
+
minify: true,
|
|
67
|
+
sourcemap: true,
|
|
68
|
+
jsx: 'automatic',
|
|
69
|
+
loader: {
|
|
70
|
+
'.ts': 'ts',
|
|
71
|
+
'.tsx': 'tsx'
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const defaultConfig = {
|
|
76
|
+
pack: {
|
|
77
|
+
tsconfig: {
|
|
78
|
+
declaration: true,
|
|
79
|
+
emitDeclarationOnly: true,
|
|
80
|
+
outDir: path.join(process.cwd(), args.outdir || "pack", 'types'),
|
|
81
|
+
strict: true,
|
|
82
|
+
allowJs: true,
|
|
83
|
+
jsx: ts.JsxEmit.React,
|
|
84
|
+
esModuleInterop: true,
|
|
85
|
+
},
|
|
86
|
+
esm: esbuild,
|
|
87
|
+
cjs: esbuild,
|
|
88
|
+
},
|
|
89
|
+
serve: {
|
|
90
|
+
express: () => { },
|
|
91
|
+
vite: {
|
|
92
|
+
root: process.cwd(),
|
|
93
|
+
plugins: [react()],
|
|
94
|
+
server: {
|
|
95
|
+
middlewareMode: true,
|
|
96
|
+
},
|
|
97
|
+
customLogger: {
|
|
98
|
+
info: (msg) => {
|
|
99
|
+
logger.info(msg)
|
|
100
|
+
},
|
|
101
|
+
warn: (msg) => logger.warning(msg),
|
|
102
|
+
error: (msg) => logger.error(msg),
|
|
103
|
+
},
|
|
104
|
+
appType: 'custom'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (fs.existsSync(makepack)) {
|
|
110
|
+
try {
|
|
111
|
+
const c = await import(pathToFileURL(makepack).href)
|
|
112
|
+
const configFn = c.default
|
|
113
|
+
if (typeof configFn === 'function') {
|
|
114
|
+
return configFn(defaultConfig)
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.log(error);
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return defaultConfig
|
|
70
122
|
}
|
package/src/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import serve from "./actions/serve/index.js";
|
|
5
|
-
import pack from "./actions/pack/index.js";
|
|
6
|
-
import create from "./actions/create/index.js";
|
|
7
|
-
|
|
8
|
-
const program = new Command();
|
|
9
|
-
|
|
10
|
-
program.name("Make Pack").description("Usages");
|
|
11
|
-
|
|
12
|
-
program
|
|
13
|
-
.command("create")
|
|
14
|
-
.description("create a new project")
|
|
15
|
-
.action(create);
|
|
16
|
-
|
|
17
|
-
program
|
|
18
|
-
.command("serve")
|
|
19
|
-
.option("-p, --port <number>", "Port number", "5000")
|
|
20
|
-
.option("-r, --root <file>", "root file")
|
|
21
|
-
.description("Start the server")
|
|
22
|
-
.action(serve);
|
|
23
|
-
|
|
24
|
-
program
|
|
25
|
-
.command("pack")
|
|
26
|
-
.option("-e, --entry <file>", "Entry file or directory (you can use a glob pattern)", "src/**/*.{tsx,ts,js,jsx}")
|
|
27
|
-
.option("-p, --publish", "Publish the project to the npm repository", false)
|
|
28
|
-
.description("Build the project and optionally publish it to the npm repository")
|
|
29
|
-
.action(pack);
|
|
30
|
-
program.parse();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import serve from "./actions/serve/index.js";
|
|
5
|
+
import pack from "./actions/pack/index.js";
|
|
6
|
+
import create from "./actions/create/index.js";
|
|
7
|
+
|
|
8
|
+
const program = new Command();
|
|
9
|
+
|
|
10
|
+
program.name("Make Pack").description("Usages");
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.command("create")
|
|
14
|
+
.description("create a new project")
|
|
15
|
+
.action(create);
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.command("serve")
|
|
19
|
+
.option("-p, --port <number>", "Port number", "5000")
|
|
20
|
+
.option("-r, --root <file>", "root file")
|
|
21
|
+
.description("Start the server")
|
|
22
|
+
.action(serve);
|
|
23
|
+
|
|
24
|
+
program
|
|
25
|
+
.command("pack")
|
|
26
|
+
.option("-e, --entry <file>", "Entry file or directory (you can use a glob pattern)", "src/**/*.{tsx,ts,js,jsx}")
|
|
27
|
+
.option("-p, --publish", "Publish the project to the npm repository", false)
|
|
28
|
+
.description("Build the project and optionally publish it to the npm repository")
|
|
29
|
+
.action(pack);
|
|
30
|
+
program.parse();
|