makepack 1.7.16 → 1.7.18

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/src/helpers.js CHANGED
@@ -1,120 +1,120 @@
1
- import child_process from 'child_process'
2
-
3
- export const execSync = (command, option = {}) => {
4
- try {
5
- const result = child_process.execSync(command, {
6
- encoding: "utf-8",
7
- stdio: 'inherit',
8
- ...option
9
- });
10
- result && console.log(result);
11
- } catch (error) {
12
- console.error(`Command failed: ${error.message}`);
13
- process.exit(1);
14
- }
15
- };
16
-
17
-
18
- export const conicon = {
19
- info: 'ℹ',
20
- success: '✔',
21
- warning: '⚠',
22
- error: '✖',
23
- };
24
-
25
- export const concolor = {
26
- red: (str) => `\x1b[31m${str}\x1b[0m`,
27
- green: (str) => `\x1b[32m${str}\x1b[0m`,
28
- yellow: (str) => `\x1b[33m${str}\x1b[0m`,
29
- blue: (str) => `\x1b[34m${str}\x1b[0m`,
30
- bold: (str) => `\x1b[1m${str}\x1b[0m`,
31
- dim: (str) => `\x1b[2m${str}\x1b[0m`,
32
- };
33
-
34
-
35
- export const logger = {
36
- log: (message, prefix, icon, color) => {
37
- let _color = concolor[color] || concolor.reset;
38
- let _icon = conicon[icon] || '';
39
- prefix = prefix ? _color(concolor.bold(prefix)) : "";
40
- console.log(`${_icon ? _color(_icon) + " " : ""}${prefix} ${message}`);
41
- },
42
- info: (message, prefix = 'INFO', icon = true) => {
43
- logger.log(message, prefix, icon ? 'info' : '', 'blue');
44
- },
45
- success: (message, prefix = 'SUCCESS:', icon = true) => {
46
- logger.log(message, prefix, icon ? 'success' : '', 'green');
47
- },
48
- warning: (message, prefix = 'WARNING:', icon = true) => {
49
- logger.log(message, prefix, icon ? 'warning' : '', 'yellow');
50
- },
51
- error: (message, prefix = 'ERROR:', icon = true) => {
52
- logger.log(message, prefix, icon ? 'error' : '', 'red');
53
- }
54
- };
55
-
56
- import fs from 'fs/promises';
57
- import path from 'path';
58
- import { pathToFileURL } from 'url';
59
-
60
- /**
61
- * Load full Vite config object from root
62
- */
63
- export async function loadViteConfig() {
64
- // List of common Vite config files
65
- const possibleFiles = [
66
- 'vite.config.js',
67
- 'vite.config.ts',
68
- 'vite.config.mjs',
69
- 'vite.config.cjs',
70
- ];
71
-
72
- for (const file of possibleFiles) {
73
- const configPath = path.resolve(process.cwd(), file);
74
-
75
- try {
76
- await fs.access(configPath); // check if file exists
77
- } catch {
78
- continue; // file doesn't exist, try next
79
- }
80
-
81
- try {
82
- const imported = await import(pathToFileURL(configPath).href);
83
- return imported.default || imported; // return full config object
84
- } catch (err) {
85
- console.error(`Failed to load ${file}:`, err);
86
- return null;
87
- }
88
- }
89
-
90
- return null; // no config found
91
- }
92
-
93
-
94
- export async function loadRollupConfig() {
95
- const possibleFiles = [
96
- 'rollup.config.js',
97
- 'rollup.config.mjs',
98
- 'rollup.config.cjs',
99
- ];
100
-
101
- for (const file of possibleFiles) {
102
- const configPath = path.resolve(process.cwd(), file);
103
-
104
- try {
105
- await fs.access(configPath); // check if file exists
106
- } catch {
107
- continue; // file doesn't exist, try next
108
- }
109
-
110
- try {
111
- const imported = await import(pathToFileURL(configPath).href);
112
- return imported.default || imported; // return full config object
113
- } catch (err) {
114
- console.error(`Failed to load ${file}:`, err);
115
- return null;
116
- }
117
- }
118
-
119
- return null;
120
- }
1
+ import child_process from 'child_process'
2
+
3
+ export const execSync = (command, option = {}) => {
4
+ try {
5
+ const result = child_process.execSync(command, {
6
+ encoding: "utf-8",
7
+ stdio: 'inherit',
8
+ ...option
9
+ });
10
+ result && console.log(result);
11
+ } catch (error) {
12
+ console.error(`Command failed: ${error.message}`);
13
+ process.exit(1);
14
+ }
15
+ };
16
+
17
+
18
+ export const conicon = {
19
+ info: 'ℹ',
20
+ success: '✔',
21
+ warning: '⚠',
22
+ error: '✖',
23
+ };
24
+
25
+ export const concolor = {
26
+ red: (str) => `\x1b[31m${str}\x1b[0m`,
27
+ green: (str) => `\x1b[32m${str}\x1b[0m`,
28
+ yellow: (str) => `\x1b[33m${str}\x1b[0m`,
29
+ blue: (str) => `\x1b[34m${str}\x1b[0m`,
30
+ bold: (str) => `\x1b[1m${str}\x1b[0m`,
31
+ dim: (str) => `\x1b[2m${str}\x1b[0m`,
32
+ };
33
+
34
+
35
+ export const logger = {
36
+ log: (message, prefix, icon, color) => {
37
+ let _color = concolor[color] || concolor.reset;
38
+ let _icon = conicon[icon] || '';
39
+ prefix = prefix ? _color(concolor.bold(prefix)) : "";
40
+ console.log(`${_icon ? _color(_icon) + " " : ""}${prefix} ${message}`);
41
+ },
42
+ info: (message, prefix = 'INFO', icon = true) => {
43
+ logger.log(message, prefix, icon ? 'info' : '', 'blue');
44
+ },
45
+ success: (message, prefix = 'SUCCESS:', icon = true) => {
46
+ logger.log(message, prefix, icon ? 'success' : '', 'green');
47
+ },
48
+ warning: (message, prefix = 'WARNING:', icon = true) => {
49
+ logger.log(message, prefix, icon ? 'warning' : '', 'yellow');
50
+ },
51
+ error: (message, prefix = 'ERROR:', icon = true) => {
52
+ logger.log(message, prefix, icon ? 'error' : '', 'red');
53
+ }
54
+ };
55
+
56
+ import fs from 'fs/promises';
57
+ import path from 'path';
58
+ import { pathToFileURL } from 'url';
59
+
60
+ /**
61
+ * Load full Vite config object from root
62
+ */
63
+ export async function loadViteConfig() {
64
+ // List of common Vite config files
65
+ const possibleFiles = [
66
+ 'vite.config.js',
67
+ 'vite.config.ts',
68
+ 'vite.config.mjs',
69
+ 'vite.config.cjs',
70
+ ];
71
+
72
+ for (const file of possibleFiles) {
73
+ const configPath = path.resolve(process.cwd(), file);
74
+
75
+ try {
76
+ await fs.access(configPath); // check if file exists
77
+ } catch {
78
+ continue; // file doesn't exist, try next
79
+ }
80
+
81
+ try {
82
+ const imported = await import(pathToFileURL(configPath).href);
83
+ return imported.default || imported; // return full config object
84
+ } catch (err) {
85
+ console.error(`Failed to load ${file}:`, err);
86
+ return null;
87
+ }
88
+ }
89
+
90
+ return null; // no config found
91
+ }
92
+
93
+
94
+ export async function loadRollupConfig() {
95
+ const possibleFiles = [
96
+ 'rollup.config.js',
97
+ 'rollup.config.mjs',
98
+ 'rollup.config.cjs',
99
+ ];
100
+
101
+ for (const file of possibleFiles) {
102
+ const configPath = path.resolve(process.cwd(), file);
103
+
104
+ try {
105
+ await fs.access(configPath); // check if file exists
106
+ } catch {
107
+ continue; // file doesn't exist, try next
108
+ }
109
+
110
+ try {
111
+ const imported = await import(pathToFileURL(configPath).href);
112
+ return imported.default || imported; // return full config object
113
+ } catch (err) {
114
+ console.error(`Failed to load ${file}:`, err);
115
+ return null;
116
+ }
117
+ }
118
+
119
+ return null;
120
+ }
package/src/index.js CHANGED
@@ -1,39 +1,39 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from "commander";
4
- import start from "./actions/start/index.js";
5
- import build from "./actions/build/index.js";
6
- import create from "./actions/create/index.js";
7
- import release from "./actions/release/index.js";
8
-
9
- const program = new Command();
10
-
11
- program.name("Makepack").description("Usages");
12
-
13
- program
14
- .command("create")
15
- .description("Create a new project")
16
- .action(create);
17
-
18
- program
19
- .command("start")
20
- .option("-p, --port <port>", "Port to run the server")
21
- .description("Start the server")
22
- .action(start);
23
-
24
- program
25
- .command("build")
26
- .description("Build the project")
27
- .option("-f, --format <format>", "Output format (cjs, esm, both)", "both")
28
- .option("-b, --bundle <bundle>", "Bundle the project", false)
29
- .option("-m, --minify <minify>", "Minify the output", false)
30
- .option("-s, --sourcemap <sourcemap>", "Generate sourcemaps", true)
31
- .option("-d, --declaration <declaration>", "Generate TypeScript declaration files", true)
32
- .action(build);
33
-
34
- program
35
- .command("release")
36
- .description("Release it to the npm repository")
37
- .action(release);
38
-
39
- program.parse();
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from "commander";
4
+ import start from "./actions/start/index.js";
5
+ import build from "./actions/build/index.js";
6
+ import create from "./actions/create/index.js";
7
+ import release from "./actions/release/index.js";
8
+
9
+ const program = new Command();
10
+
11
+ program.name("Makepack").description("Usages");
12
+
13
+ program
14
+ .command("create")
15
+ .description("Create a new project")
16
+ .action(create);
17
+
18
+ program
19
+ .command("start")
20
+ .option("-p, --port <port>", "Port to run the server")
21
+ .description("Start the server")
22
+ .action(start);
23
+
24
+ program
25
+ .command("build")
26
+ .description("Build the project")
27
+ .option("-f, --format <format>", "Output format (cjs, esm, both)", "both")
28
+ .option("-b, --bundle <bundle>", "Bundle the project", false)
29
+ .option("-m, --minify <minify>", "Minify the output", false)
30
+ .option("-s, --sourcemap <sourcemap>", "Generate sourcemaps", true)
31
+ .option("-d, --declaration <declaration>", "Generate TypeScript declaration files", true)
32
+ .action(build);
33
+
34
+ program
35
+ .command("release")
36
+ .description("Release it to the npm repository")
37
+ .action(release);
38
+
39
+ program.parse();