@bundlekit/service 0.0.1
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/dist/chunks/build-BWky34L_.mjs +21 -0
- package/dist/chunks/build-DksjZoFJ.cjs +23 -0
- package/dist/chunks/help-BJWxLw5O.mjs +49 -0
- package/dist/chunks/help-CqnZdJwq.cjs +51 -0
- package/dist/chunks/serve-B-j5a77h.mjs +55 -0
- package/dist/chunks/serve-C1wcFsjj.cjs +57 -0
- package/dist/index.cjs +3468 -0
- package/dist/index.mjs +3451 -0
- package/package.json +86 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var build = {
|
|
2
|
+
defaultModes: {
|
|
3
|
+
build: "production",
|
|
4
|
+
},
|
|
5
|
+
apply: (api, options) => {
|
|
6
|
+
// 注册命令
|
|
7
|
+
api.registerCommand("build", {
|
|
8
|
+
description: "打包生产环境服务, 'bundlekit-serve build [options] [entry]' 启动开发服务",
|
|
9
|
+
usage: "bundlekit build [options] [entry]",
|
|
10
|
+
options: {
|
|
11
|
+
"--mode": "声明运行的环境 (默认: production)",
|
|
12
|
+
"--skip-plugins": "跳过指定的插件(多个插件以逗号分隔)",
|
|
13
|
+
}
|
|
14
|
+
}, async (args, rawArgv = []) => {
|
|
15
|
+
// 开始构建
|
|
16
|
+
api.service.startBuilder();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { build as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var build = {
|
|
4
|
+
defaultModes: {
|
|
5
|
+
build: "production",
|
|
6
|
+
},
|
|
7
|
+
apply: (api, options) => {
|
|
8
|
+
// 注册命令
|
|
9
|
+
api.registerCommand("build", {
|
|
10
|
+
description: "打包生产环境服务, 'bundlekit-serve build [options] [entry]' 启动开发服务",
|
|
11
|
+
usage: "bundlekit build [options] [entry]",
|
|
12
|
+
options: {
|
|
13
|
+
"--mode": "声明运行的环境 (默认: production)",
|
|
14
|
+
"--skip-plugins": "跳过指定的插件(多个插件以逗号分隔)",
|
|
15
|
+
}
|
|
16
|
+
}, async (args, rawArgv = []) => {
|
|
17
|
+
// 开始构建
|
|
18
|
+
api.service.startBuilder();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.default = build;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Logger } from '@bundlekit/shared-utils';
|
|
2
|
+
|
|
3
|
+
var help = {
|
|
4
|
+
defaultModes: {
|
|
5
|
+
help: "developement",
|
|
6
|
+
},
|
|
7
|
+
apply: (api, options) => {
|
|
8
|
+
const logger = new Logger();
|
|
9
|
+
const commands = api.service.commands;
|
|
10
|
+
function printHelp() {
|
|
11
|
+
// 打印帮助信息
|
|
12
|
+
for (const command in commands) {
|
|
13
|
+
if (command === "help") {
|
|
14
|
+
logger.done("使用方法:", command);
|
|
15
|
+
const { opts } = commands[command];
|
|
16
|
+
if (typeof opts !== "function") {
|
|
17
|
+
logger.printRecord(opts.options);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function printAllCommandUsage() {
|
|
23
|
+
for (const command in commands) {
|
|
24
|
+
if (command !== "help") {
|
|
25
|
+
logger.done("使用方法:", command);
|
|
26
|
+
const { opts } = commands[command];
|
|
27
|
+
if (typeof opts !== "function") {
|
|
28
|
+
logger.printRecord(opts.options);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
api.registerCommand("help", {
|
|
34
|
+
description: "打包生产环境服务, 'bundlekit-serve help 打印帮助信息",
|
|
35
|
+
usage: "bundlekit-service help",
|
|
36
|
+
options: {
|
|
37
|
+
"--help": "输出帮助信息",
|
|
38
|
+
"--version": "输出当前bundlekit-service版本",
|
|
39
|
+
}
|
|
40
|
+
}, async (args, rawArgv = []) => {
|
|
41
|
+
// 打印帮助信息
|
|
42
|
+
const command = args._[0];
|
|
43
|
+
console.log("args", args, rawArgv);
|
|
44
|
+
!command ? printAllCommandUsage() : printHelp();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { help as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sharedUtils = require('@bundlekit/shared-utils');
|
|
4
|
+
|
|
5
|
+
var help = {
|
|
6
|
+
defaultModes: {
|
|
7
|
+
help: "developement",
|
|
8
|
+
},
|
|
9
|
+
apply: (api, options) => {
|
|
10
|
+
const logger = new sharedUtils.Logger();
|
|
11
|
+
const commands = api.service.commands;
|
|
12
|
+
function printHelp() {
|
|
13
|
+
// 打印帮助信息
|
|
14
|
+
for (const command in commands) {
|
|
15
|
+
if (command === "help") {
|
|
16
|
+
logger.done("使用方法:", command);
|
|
17
|
+
const { opts } = commands[command];
|
|
18
|
+
if (typeof opts !== "function") {
|
|
19
|
+
logger.printRecord(opts.options);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function printAllCommandUsage() {
|
|
25
|
+
for (const command in commands) {
|
|
26
|
+
if (command !== "help") {
|
|
27
|
+
logger.done("使用方法:", command);
|
|
28
|
+
const { opts } = commands[command];
|
|
29
|
+
if (typeof opts !== "function") {
|
|
30
|
+
logger.printRecord(opts.options);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
api.registerCommand("help", {
|
|
36
|
+
description: "打包生产环境服务, 'bundlekit-serve help 打印帮助信息",
|
|
37
|
+
usage: "bundlekit-service help",
|
|
38
|
+
options: {
|
|
39
|
+
"--help": "输出帮助信息",
|
|
40
|
+
"--version": "输出当前bundlekit-service版本",
|
|
41
|
+
}
|
|
42
|
+
}, async (args, rawArgv = []) => {
|
|
43
|
+
// 打印帮助信息
|
|
44
|
+
const command = args._[0];
|
|
45
|
+
console.log("args", args, rawArgv);
|
|
46
|
+
!command ? printAllCommandUsage() : printHelp();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.default = help;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { g as getDefaultConfig } from '../index.mjs';
|
|
2
|
+
import 'path';
|
|
3
|
+
import 'jiti';
|
|
4
|
+
import '@bundlekit/shared-utils';
|
|
5
|
+
import 'node:http';
|
|
6
|
+
import 'module';
|
|
7
|
+
|
|
8
|
+
var serve = {
|
|
9
|
+
defaultModes: {
|
|
10
|
+
serve: "development",
|
|
11
|
+
},
|
|
12
|
+
apply: (api, options) => {
|
|
13
|
+
const defaultConfig = getDefaultConfig(api.service.context);
|
|
14
|
+
api.registerCommand("serve", {
|
|
15
|
+
description: "开启开发环境服务, 'bundlekit-serve serve [options] [entry]' 启动开发服务",
|
|
16
|
+
usage: "bundlekit serve [options] [entry]",
|
|
17
|
+
options: {
|
|
18
|
+
"--open": "利用浏览器打开页面地址",
|
|
19
|
+
"--stdin": "当stdin被关闭时,关闭服务器。",
|
|
20
|
+
"--mode": "声明运行的环境 (默认: development)",
|
|
21
|
+
"--host": `声明支持的hostname (默认: ${defaultConfig.config.development.devServer?.host || "0.0.0.0"})`,
|
|
22
|
+
"--port": `声明端口号 (默认: ${defaultConfig.config.development.devServer?.port || 3000})`,
|
|
23
|
+
"--https": `使用https (默认: ${defaultConfig.config.development.devServer?.https ? "true" : "false"})`,
|
|
24
|
+
"--bundler": `指定构建工具来构建(默认: ${defaultConfig.bundler})`,
|
|
25
|
+
"--skip-plugin": "跳过指定插件,多个插件用逗号分隔",
|
|
26
|
+
}
|
|
27
|
+
}, async (args, rawArgv = []) => {
|
|
28
|
+
const buildConfig = api.service.getBuildConfig();
|
|
29
|
+
if (!buildConfig)
|
|
30
|
+
return;
|
|
31
|
+
const mode = (args.mode || buildConfig.mode || "development");
|
|
32
|
+
const envConfig = buildConfig.config?.[mode] || buildConfig.config?.development || {};
|
|
33
|
+
envConfig.devServer = {
|
|
34
|
+
...(envConfig.devServer || {}),
|
|
35
|
+
...(args.open !== undefined && { open: !!args.open }),
|
|
36
|
+
...(args.host !== undefined && { host: args.host }),
|
|
37
|
+
...(args.port !== undefined && { port: Number(args.port) }),
|
|
38
|
+
...(args.https !== undefined && { https: !!args.https }),
|
|
39
|
+
};
|
|
40
|
+
if (args.bundler) {
|
|
41
|
+
buildConfig.bundler = args.bundler;
|
|
42
|
+
}
|
|
43
|
+
if (args.stdin) {
|
|
44
|
+
process.stdin.on('end', () => {
|
|
45
|
+
api.service.logger.log('stdin 已关闭,正在关闭服务器...', "开发服务");
|
|
46
|
+
process.exit(0);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
api.service.setBuildConfig(buildConfig);
|
|
50
|
+
api.service.startBuilder();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { serve as default };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('../index.cjs');
|
|
4
|
+
require('path');
|
|
5
|
+
require('jiti');
|
|
6
|
+
require('@bundlekit/shared-utils');
|
|
7
|
+
require('node:http');
|
|
8
|
+
require('module');
|
|
9
|
+
|
|
10
|
+
var serve = {
|
|
11
|
+
defaultModes: {
|
|
12
|
+
serve: "development",
|
|
13
|
+
},
|
|
14
|
+
apply: (api, options) => {
|
|
15
|
+
const defaultConfig = index.getDefaultConfig(api.service.context);
|
|
16
|
+
api.registerCommand("serve", {
|
|
17
|
+
description: "开启开发环境服务, 'bundlekit-serve serve [options] [entry]' 启动开发服务",
|
|
18
|
+
usage: "bundlekit serve [options] [entry]",
|
|
19
|
+
options: {
|
|
20
|
+
"--open": "利用浏览器打开页面地址",
|
|
21
|
+
"--stdin": "当stdin被关闭时,关闭服务器。",
|
|
22
|
+
"--mode": "声明运行的环境 (默认: development)",
|
|
23
|
+
"--host": `声明支持的hostname (默认: ${defaultConfig.config.development.devServer?.host || "0.0.0.0"})`,
|
|
24
|
+
"--port": `声明端口号 (默认: ${defaultConfig.config.development.devServer?.port || 3000})`,
|
|
25
|
+
"--https": `使用https (默认: ${defaultConfig.config.development.devServer?.https ? "true" : "false"})`,
|
|
26
|
+
"--bundler": `指定构建工具来构建(默认: ${defaultConfig.bundler})`,
|
|
27
|
+
"--skip-plugin": "跳过指定插件,多个插件用逗号分隔",
|
|
28
|
+
}
|
|
29
|
+
}, async (args, rawArgv = []) => {
|
|
30
|
+
const buildConfig = api.service.getBuildConfig();
|
|
31
|
+
if (!buildConfig)
|
|
32
|
+
return;
|
|
33
|
+
const mode = (args.mode || buildConfig.mode || "development");
|
|
34
|
+
const envConfig = buildConfig.config?.[mode] || buildConfig.config?.development || {};
|
|
35
|
+
envConfig.devServer = {
|
|
36
|
+
...(envConfig.devServer || {}),
|
|
37
|
+
...(args.open !== undefined && { open: !!args.open }),
|
|
38
|
+
...(args.host !== undefined && { host: args.host }),
|
|
39
|
+
...(args.port !== undefined && { port: Number(args.port) }),
|
|
40
|
+
...(args.https !== undefined && { https: !!args.https }),
|
|
41
|
+
};
|
|
42
|
+
if (args.bundler) {
|
|
43
|
+
buildConfig.bundler = args.bundler;
|
|
44
|
+
}
|
|
45
|
+
if (args.stdin) {
|
|
46
|
+
process.stdin.on('end', () => {
|
|
47
|
+
api.service.logger.log('stdin 已关闭,正在关闭服务器...', "开发服务");
|
|
48
|
+
process.exit(0);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
api.service.setBuildConfig(buildConfig);
|
|
52
|
+
api.service.startBuilder();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.default = serve;
|