makepack 1.7.21 → 1.7.22

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