oipage 0.1.0-alpha.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.
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: ['https://zxl20070701.github.io/notebook/home.html']
package/.mailmap ADDED
@@ -0,0 +1 @@
1
+ zxl20070701 <1904314465@qq.com>
package/AUTHORS.txt ADDED
@@ -0,0 +1,6 @@
1
+ Authors ordered by first contribution.
2
+
3
+ zxl20070701 <1904314465@qq.com> <https://github.com/zxl20070701>
4
+
5
+ -----------------------------------------------------
6
+ We thank all of them for their contributions!
package/CHANGELOG ADDED
File without changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) zxl20070701 走一步,再走一步
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # [OIPage](https://github.com/oi-contrib/OIPage)
2
+ 📰跨端前端框架,支持H5+各种小程序等,并支持扩展前端开发框架(比如使用Vue或React语法开发)
3
+
4
+ <p>
5
+ <a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=oipage&interval=7">
6
+ <img src="https://img.shields.io/npm/dm/oipage.svg" alt="downloads">
7
+ </a>
8
+ <a href="https://www.npmjs.com/package/oipage">
9
+ <img src="https://img.shields.io/npm/v/oipage.svg" alt="Version">
10
+ </a>
11
+ <a href="https://github.com/zxl20070701/OIPage" target='_blank'>
12
+ <img alt="GitHub repo stars" src="https://img.shields.io/github/stars/zxl20070701/OIPage?style=social">
13
+ </a>
14
+ </p>
15
+
16
+ <img src="https://nodei.co/npm/oipage.png?downloads=true&amp;downloadRank=true&amp;stars=true" alt="NPM">
17
+
18
+ ## 版权
19
+
20
+ MIT License
21
+
22
+ Copyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) 走一步,再走一步
package/bin/options.js ADDED
@@ -0,0 +1,40 @@
1
+ module.exports = {
2
+
3
+ // 命令参数配置
4
+ "options": {
5
+ version: {
6
+ short: 'v',
7
+ info: '[0]Display the version of OIPage.',
8
+ demo: 'oipage-cli --version|-v'
9
+ },
10
+ help: {
11
+ short: 'h',
12
+ info: '[1]Display this help text.',
13
+ demo: 'oipage-cli --help|-h <term>'
14
+ },
15
+ root: {
16
+ info: '[2]Set project root directory.',
17
+ demo: 'oipage-cli --root ./'
18
+ },
19
+ dev: {
20
+ info: '[3]Development mode running project.',
21
+ demo: 'oipage-cli --dev h5|mp-weixin'
22
+ },
23
+ build: {
24
+ info: '[4]Package the current project.',
25
+ demo: 'oipage-cli --build h5|mp-weixin'
26
+ }
27
+ },
28
+
29
+ // 帮助信息
30
+ "help": `
31
+ Usage: oipage-cli <command>
32
+
33
+ Where <command> is one of:
34
+ --help, -h, --version, -v, --root, --dev, --build
35
+
36
+ oipage-cli --help|-h <term> search for help on <term>
37
+ oipage-cli --help|-h involved overview
38
+ `
39
+
40
+ };
package/bin/run ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ process.title = 'oipage-cli';
6
+
7
+ const devby = require("devby");
8
+ const { options, help } = require('./options');
9
+ const pkg = require("../package.json");
10
+ const runDev = require("../script/command/dev");
11
+ const runBuild = require("../script/command/build");
12
+ const alignment = require("../script/config/alignment");
13
+
14
+ // 组装好缩写和全写的映射
15
+ let shortHands = {};
16
+ for (let key in options) {
17
+ if (options[key].short) shortHands["-" + options[key].short] = "--" + key;
18
+ }
19
+
20
+ // 命令行传递的参数
21
+ const parsed = devby.options(shortHands, process.argv);
22
+
23
+ (() => {
24
+ // 打印版本
25
+ if (Array.isArray(parsed.version)) {
26
+ devby.log("\nOIPage@v" + pkg.version + "\n");
27
+ }
28
+
29
+ // 判断是否需要帮助
30
+ else if (Array.isArray(parsed.help)) {
31
+ // 打印具体的配置提示
32
+ if (parsed.help.length > 0) {
33
+ let help0 = parsed.help[0];
34
+
35
+ // 缩写转全拼
36
+ if (help0.length == 1) {
37
+ help0 = shortHands["-" + help0];
38
+ }
39
+
40
+ if (help0) {
41
+ help0 = help0.replace(/^--/, "");
42
+
43
+ // 根据需要帮助的命令获取对应的信息
44
+ const help0Option = options[help0];
45
+ if (help0Option) {
46
+ devby.log(`
47
+ ` + help0Option.demo + ` ` + help0Option.info + `
48
+ `);
49
+
50
+ return;
51
+ }
52
+
53
+ }
54
+ }
55
+
56
+ devby.log(help);
57
+ }
58
+
59
+ // 开发
60
+ else if (Array.isArray(parsed.dev)) {
61
+ runDev(alignment.command(parsed));
62
+ }
63
+
64
+ // 打包
65
+ else if (Array.isArray(parsed.build)) {
66
+ runBuild(alignment.command(parsed));
67
+ }
68
+
69
+ // 默认
70
+ else {
71
+ devby.log(help);
72
+ }
73
+ })();
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "oipage",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "📰跨端前端框架,支持H5+各种小程序等,并支持扩展前端开发框架(比如使用Vue或React语法开发)",
5
+ "main": "",
6
+ "typings": "./types/index.d.ts",
7
+ "scripts": {
8
+ "build": "npm pack",
9
+ "dev:h5": "node bin/run --dev h5 --root ./test",
10
+ "dev:mp-weixin": "node bin/run --dev mp-weixin --root ./test",
11
+ "build:h5": "node bin/run --build h5 --root ./test",
12
+ "build:mp-weixin": "node bin/run --build mp-weixin --root ./test"
13
+ },
14
+ "bin": {
15
+ "oipage-cli": "bin/run"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/oi-contrib/OIPage.git"
20
+ },
21
+ "keywords": [
22
+ "oi-contrib",
23
+ "oipage",
24
+ "framework"
25
+ ],
26
+ "author": {
27
+ "name": "zxl20070701",
28
+ "url": "https://zxl20070701.github.io/notebook/home.html"
29
+ },
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/oi-contrib/OIPage/issues"
33
+ },
34
+ "homepage": "https://oi-contrib.github.io/OIPage",
35
+ "dependencies": {
36
+ "devby": "^0.6.0",
37
+ "html-webpack-plugin": "^5.6.0",
38
+ "webpack": "^5.91.0",
39
+ "webpack-dev-server": "^5.0.4"
40
+ }
41
+ }
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-cn">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title><%= htmlWebpackPlugin.options.title %></title>
8
+ </head>
9
+
10
+ <body>
11
+
12
+ </body>
13
+
14
+ </html>
@@ -0,0 +1,22 @@
1
+ const Webpack = require("webpack");
2
+ const { log } = require("devby");
3
+
4
+ const getWebpackConfig = require("../config/webpack");
5
+
6
+ module.exports = function (parsed) {
7
+ const webpackConfig = getWebpackConfig(parsed);
8
+
9
+ // https://webpack.docschina.org/api/node/#webpack
10
+ const compiler = Webpack(webpackConfig);
11
+
12
+ compiler.run((err, stats) => {
13
+ if (err || stats.hasErrors()) {
14
+ console.error(err || stats.toJson().errors);
15
+ }
16
+
17
+ log("<日志> [OIPage] 打包完成:" + webpackConfig.output.path.replace(process.cwd(), '.') + "\n")
18
+ compiler.close((closeErr) => {
19
+ if (closeErr) console.error(closeErr);
20
+ });
21
+ });
22
+ };
@@ -0,0 +1,38 @@
1
+ const Webpack = require("webpack");
2
+ const WebpackDevServer = require("webpack-dev-server");
3
+ const { log } = require("devby");
4
+
5
+ const getWebpackConfig = require("../config/webpack");
6
+
7
+ module.exports = function (parsed) {
8
+ const webpackConfig = getWebpackConfig(parsed);
9
+
10
+ if (parsed.platform == "h5") {
11
+ const compiler = Webpack(webpackConfig);
12
+
13
+ // https://webpack.docschina.org/api/webpack-dev-server
14
+ const server = new WebpackDevServer(webpackConfig.devServer, compiler);
15
+
16
+ server.start().then(function () {
17
+ // todo
18
+ });
19
+ } else {
20
+ const compiler = Webpack(webpackConfig);
21
+
22
+ const watching = compiler.watch(webpackConfig.watchOptions, (err, stats) => {
23
+ if (err || stats.hasErrors()) {
24
+ console.error(err || stats.toJson().errors);
25
+ }
26
+
27
+ // 编译成功后的逻辑
28
+ console.log(stats.toString({ colors: true }));
29
+ });
30
+
31
+ watching.close((closeErr) => {
32
+ if (closeErr) console.error(closeErr);
33
+ log("<日志> [OIPage] 退出监听:" + parsed.platform + "\n");
34
+ });
35
+
36
+ }
37
+
38
+ };
@@ -0,0 +1,15 @@
1
+
2
+ // 对齐命令行解析后的参数
3
+ exports.command = function (parsed) {
4
+ return {
5
+
6
+ // 生产还是开发
7
+ mode: Array.isArray(parsed.build) ? "production" : "development",
8
+
9
+ // 平台
10
+ platform: (Array.isArray(parsed.build) ? parsed.build[0] : parsed.dev[0]) || "h5",
11
+
12
+ // 项目根目录
13
+ root: (Array.isArray(parsed.root) && parsed.root[0]) ? parsed.root[0] : "./"
14
+ };
15
+ };
@@ -0,0 +1,60 @@
1
+ const path = require('path');
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
3
+
4
+ module.exports = function (parsed) {
5
+
6
+ const config = {
7
+ entry: path.resolve(process.cwd(), parsed.root, "./src/app.js"),
8
+ mode: parsed.mode,
9
+ plugins: []
10
+ };
11
+
12
+ // 开发模式
13
+ if (parsed.mode == "development") {
14
+
15
+ // H5环境
16
+ if (parsed.platform == "h5") {
17
+ config.devServer = {
18
+ open: false,
19
+ host: '0.0.0.0',
20
+ port: 8080,
21
+ hot: true,
22
+ compress: false,
23
+ historyApiFallback: true
24
+ };
25
+ }
26
+
27
+ // 其它环境
28
+ else {
29
+ config.output = {
30
+ path: path.resolve(process.cwd(), parsed.root, "./dist/dev/" + parsed.platform),
31
+ clean: false
32
+ };
33
+
34
+ config.watchOptions = {
35
+ aggregateTimeout: 600, // 当第一个文件更改,会在重新构建前增加延迟
36
+ poll: 5007, // 指定毫秒为单位进行轮询
37
+ ignored: ['**/node_modules'], // 排除像 node_modules 如此庞大的文件夹
38
+ };
39
+ }
40
+
41
+ }
42
+
43
+ // 生产模式
44
+ else {
45
+ config.output = {
46
+ path: path.resolve(process.cwd(), parsed.root, "./dist/build/" + parsed.platform),
47
+ clean: true
48
+ };
49
+ }
50
+
51
+ // H5环境
52
+ if (parsed.platform == "h5") {
53
+ config.plugins.push(new HtmlWebpackPlugin({
54
+ template: path.resolve(__dirname, '../../public/index.html'),
55
+ title: "OIPage"
56
+ }));
57
+ }
58
+
59
+ return config;
60
+ };
File without changes
File without changes
File without changes