makepack 1.3.4 → 1.3.6
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 +4 -2
- 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 +112 -76
- package/src/actions/serve/index.js +106 -106
- package/src/helpers.js +69 -69
- package/src/index.js +30 -30
package/src/helpers.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
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
|
-
export const logLoader = (message = "") => {
|
|
10
|
-
const spinner = ['|', '/', '-', '\\'];
|
|
11
|
-
let i = 0;
|
|
12
|
-
const interval = setInterval(() => {
|
|
13
|
-
process.stdout.write(`\r${message} ${spinner[i]}`);
|
|
14
|
-
i = (i + 1) % spinner.length;
|
|
15
|
-
}, 100);
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
stop: (msg) => {
|
|
19
|
-
clearInterval(interval);
|
|
20
|
-
!!msg && console.log(`\r${msg}`);
|
|
21
|
-
process.stdout.write(`\r`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const execSync = (command, option = {}) => {
|
|
27
|
-
try {
|
|
28
|
-
const result = child_process.execSync(command, {
|
|
29
|
-
encoding: "utf-8",
|
|
30
|
-
stdio: 'inherit',
|
|
31
|
-
...option
|
|
32
|
-
});
|
|
33
|
-
result && console.log(result);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.error(`Command failed: ${error.message}`);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export const logger = {
|
|
43
|
-
info: (message, prefix = 'INFO', icon = true) => {
|
|
44
|
-
console.log(`${icon ? chalk.blue(figures.info) + " " : ""}${chalk.cyan.bold(prefix)} ${message}`);
|
|
45
|
-
},
|
|
46
|
-
success: (message, prefix = 'SUCCESS:', icon = true) => {
|
|
47
|
-
console.log(`${icon ? chalk.green(figures.tick) + " " : ""}${chalk.green.bold(prefix)} ${message}`);
|
|
48
|
-
},
|
|
49
|
-
warning: (message, prefix = 'WARNING:', icon = true) => {
|
|
50
|
-
console.log(`${icon ? chalk.yellow(figures.warning) + " " : ""}${chalk.yellow.bold(prefix)} ${message}`);
|
|
51
|
-
},
|
|
52
|
-
error: (message, prefix = 'ERROR:', icon = true) => {
|
|
53
|
-
console.log(`${icon ? chalk.red(figures.cross) + " " : ""}${chalk.red.bold(prefix)} ${message}`);
|
|
54
|
-
},
|
|
55
|
-
custom: (icon, color, label, message) => {
|
|
56
|
-
console.log(`${chalk[color](icon)} ${chalk[color].bold(`${label}:`)} ${message}`);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export const loadConfig = async (file) => {
|
|
62
|
-
const
|
|
63
|
-
if (fs.existsSync(
|
|
64
|
-
try {
|
|
65
|
-
const c = await import(pathToFileURL(
|
|
66
|
-
return c.default || {}
|
|
67
|
-
} catch (error) {
|
|
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
|
+
|
|
8
|
+
|
|
9
|
+
export const logLoader = (message = "") => {
|
|
10
|
+
const spinner = ['|', '/', '-', '\\'];
|
|
11
|
+
let i = 0;
|
|
12
|
+
const interval = setInterval(() => {
|
|
13
|
+
process.stdout.write(`\r${message} ${spinner[i]}`);
|
|
14
|
+
i = (i + 1) % spinner.length;
|
|
15
|
+
}, 100);
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
stop: (msg) => {
|
|
19
|
+
clearInterval(interval);
|
|
20
|
+
!!msg && console.log(`\r${msg}`);
|
|
21
|
+
process.stdout.write(`\r`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const execSync = (command, option = {}) => {
|
|
27
|
+
try {
|
|
28
|
+
const result = child_process.execSync(command, {
|
|
29
|
+
encoding: "utf-8",
|
|
30
|
+
stdio: 'inherit',
|
|
31
|
+
...option
|
|
32
|
+
});
|
|
33
|
+
result && console.log(result);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error(`Command failed: ${error.message}`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export const logger = {
|
|
43
|
+
info: (message, prefix = 'INFO', icon = true) => {
|
|
44
|
+
console.log(`${icon ? chalk.blue(figures.info) + " " : ""}${chalk.cyan.bold(prefix)} ${message}`);
|
|
45
|
+
},
|
|
46
|
+
success: (message, prefix = 'SUCCESS:', icon = true) => {
|
|
47
|
+
console.log(`${icon ? chalk.green(figures.tick) + " " : ""}${chalk.green.bold(prefix)} ${message}`);
|
|
48
|
+
},
|
|
49
|
+
warning: (message, prefix = 'WARNING:', icon = true) => {
|
|
50
|
+
console.log(`${icon ? chalk.yellow(figures.warning) + " " : ""}${chalk.yellow.bold(prefix)} ${message}`);
|
|
51
|
+
},
|
|
52
|
+
error: (message, prefix = 'ERROR:', icon = true) => {
|
|
53
|
+
console.log(`${icon ? chalk.red(figures.cross) + " " : ""}${chalk.red.bold(prefix)} ${message}`);
|
|
54
|
+
},
|
|
55
|
+
custom: (icon, color, label, message) => {
|
|
56
|
+
console.log(`${chalk[color](icon)} ${chalk[color].bold(`${label}:`)} ${message}`);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
export const loadConfig = async (file) => {
|
|
62
|
+
const config = path.resolve(process.cwd(), file);
|
|
63
|
+
if (fs.existsSync(config)) {
|
|
64
|
+
try {
|
|
65
|
+
const c = await import(pathToFileURL(config).href)
|
|
66
|
+
return c.default || {}
|
|
67
|
+
} catch (error) {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
70
|
}
|
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();
|