tmui-cli 1.1.8 → 1.1.9

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/bin/cmdTool.js CHANGED
@@ -1,13 +1,12 @@
1
- import fs from "fs"
2
- import path from "path"
3
- import {
4
- spawn,
5
- exec
6
- } from "child_process"
7
- import process from "process"
8
- import codecs from "codecs"
9
- import psTree from "ps-tree"
10
- import iconv from "iconv-lite"
1
+
2
+ const path = require("path")
3
+ const fs = require("fs")
4
+ const {spawn,exec} = require("child_process")
5
+ const process = require("process")
6
+ const codecs = require("codecs")
7
+ const psTree = require("ps-tree")
8
+
9
+
11
10
 
12
11
 
13
12
  function detectEncoding(str) {
@@ -30,7 +29,7 @@ function send(ws, arg) {
30
29
  })
31
30
  }
32
31
 
33
- export function execCmd(cb, end, command) {
32
+ function execCmd(cb, end, command) {
34
33
  try {
35
34
  // const npmPath = path.join(process.env.APPDATA, 'npm', 'npm.cmd');
36
35
  const spawnObj = exec(command, {
@@ -81,7 +80,7 @@ export function execCmd(cb, end, command) {
81
80
  }
82
81
  }
83
82
  // 杀死子进程及其所有子孙进程
84
- export function killChildAndGrandChildren(pid) {
83
+ function killChildAndGrandChildren(pid) {
85
84
 
86
85
  if (process.platform === 'win32') {
87
86
  // 在 Windows 系统上执行的代码
@@ -104,7 +103,7 @@ export function killChildAndGrandChildren(pid) {
104
103
 
105
104
  }
106
105
 
107
- export function devRunApp(ws, obj) {
106
+ function devRunApp(ws, obj) {
108
107
 
109
108
  const nowcd = process.cwd();
110
109
  process.chdir(path.normalize(obj.data.path));
@@ -172,7 +171,7 @@ export function devRunApp(ws, obj) {
172
171
  return childreProcess;
173
172
  }
174
173
 
175
- export function buildApp(ws, obj, end) {
174
+ function buildApp(ws, obj, end) {
176
175
 
177
176
  const nowcd = process.cwd();
178
177
  process.chdir(path.normalize(obj.data.path));
@@ -220,4 +219,11 @@ export function buildApp(ws, obj, end) {
220
219
  return childreProcess;
221
220
  }
222
221
 
222
+ module.exports = {
223
+ execCmd,
224
+ killChildAndGrandChildren,
225
+ devRunApp,
226
+ buildApp
227
+ }
228
+
223
229
 
package/bin/createTmui.js CHANGED
@@ -1,7 +1,8 @@
1
- import path from "path";
2
- import fs from "fs"
3
- import compressing from "compressing"
4
- import { execCmd } from "./cmdTool.js";
1
+
2
+ const path = require("path")
3
+ const {execCmd} = require("./cmdTool.js")
4
+ const fs = require("fs")
5
+ const compressing = require("compressing")
5
6
 
6
7
 
7
8
  const uniappDevListVer = [
@@ -77,7 +78,7 @@ function writePackageJson(filepath, str) {
77
78
  * @param {(str)=>{}} call
78
79
  * @param {()=>{}} end
79
80
  */
80
- export async function UpdateTmui(arg, call, end) {
81
+ async function UpdateTmui(arg, call, end) {
81
82
  let rootdir = path.normalize(arg.path)
82
83
  call('检测目录...')
83
84
  if (!fs.existsSync(rootdir)) {
@@ -204,7 +205,7 @@ export async function UpdateTmui(arg, call, end) {
204
205
  * @param {(str)=>{}} call
205
206
  * @param {(str?:string)=>{}} end
206
207
  */
207
- export async function createTmui(arg, call, end) {
208
+ async function createTmui(arg, call, end) {
208
209
  let rootdir = path.normalize(arg.rootDir)
209
210
  call('检测目录...')
210
211
  if (!fs.existsSync(rootdir)) {
@@ -372,4 +373,9 @@ export async function createTmui(arg, call, end) {
372
373
 
373
374
  end(rootdir)
374
375
 
376
+ }
377
+
378
+ module.exports = {
379
+ createTmui,
380
+ UpdateTmui
375
381
  }
package/bin/dirTool.js CHANGED
@@ -1,14 +1,7 @@
1
- import fs from "fs"
2
- import path from "path"
3
- import {
4
- spawn,
5
- exec
6
- } from "child_process"
7
- import process from "process"
8
- import os from "os"
1
+ const path = require("path")
2
+ const fs = require("fs")
9
3
 
10
-
11
- export function getJsonFiles(jsonPath) {
4
+ function getJsonFiles(jsonPath) {
12
5
  let jsonFiles = [];
13
6
 
14
7
  function findJsonFile(www) {
@@ -28,7 +21,7 @@ export function getJsonFiles(jsonPath) {
28
21
  return jsonFiles;
29
22
  }
30
23
 
31
- export function getJsonDir(basePath = './') {
24
+ function getJsonDir(basePath = './') {
32
25
  const dirPath = basePath;
33
26
  const root = {
34
27
  name: '',
@@ -71,6 +64,7 @@ export function getJsonDir(basePath = './') {
71
64
  }
72
65
 
73
66
  }
67
+ // @ts-ignore
74
68
  root.children = tree;
75
69
 
76
70
 
@@ -78,7 +72,7 @@ export function getJsonDir(basePath = './') {
78
72
  }
79
73
 
80
74
  /**读取项目信息根据提供的路径。 */
81
- export function checkProject(obj) {
75
+ function checkProject(obj) {
82
76
 
83
77
  // const {id,path,type} = obj;
84
78
  let mainsetStrPath = "";
@@ -150,3 +144,9 @@ export function checkProject(obj) {
150
144
  }
151
145
  }
152
146
 
147
+
148
+ module.exports = {
149
+ getJsonFiles,
150
+ getJsonDir,
151
+ checkProject
152
+ }
package/bin/hooks.js CHANGED
@@ -1,13 +1,15 @@
1
+ const figlet = require("figlet")
2
+ const chalks = import("chalk")
3
+
4
+ const {createTmui,UpdateTmui} = require("./createTmui.js")
5
+ const {checkProject} = require("./dirTool.js")
6
+ const {selectedDir} = require("./selectedDir.js")
7
+ const osUtils = require("node-os-utils")
8
+ const {WebSocketServer} = require("ws")
9
+ const {execCmd, devRunApp, killChildAndGrandChildren, buildApp} = require("./cmdTool.js")
10
+
1
11
 
2
- import {WebSocketServer} from 'ws'
3
- import osUtils from 'node-os-utils'
4
- import { execCmd, devRunApp, killChildAndGrandChildren, buildApp } from './cmdTool.js'
5
- import { selectedDir } from './selectedDir.js'
6
- import { checkProject} from './dirTool.js'
7
- import { Chalk } from "chalk";
8
- import { createTmui,UpdateTmui } from './createTmui.js'
9
12
 
10
- let chalk = new Chalk()
11
13
 
12
14
 
13
15
 
@@ -54,7 +56,8 @@ function send(arg) {
54
56
  el.send(arg)
55
57
  })
56
58
  }
57
- wss.on('connection', function connection(ws) {
59
+ wss.on('connection', async function connection(ws) {
60
+ const chalk = (await chalks).default;
58
61
 
59
62
  ws.uuid = uuid();
60
63
  wslist.push(ws)
package/bin/net.js CHANGED
@@ -1,11 +1,8 @@
1
- import express from "express"
2
- import fs from "fs"
3
- import {spawn} from "child_process"
4
- import iconv from "iconv-lite"
5
- import BufferHelper from "bufferhelper"
6
- import open from "open"
7
- import bodyParser from "body-parser"
8
- import fetch from "node-fetch"
1
+ const Open = import("open")
2
+ const bodyParser = require("body-parser")
3
+ const Fetch = import("node-fetch")
4
+ const express = require("express")
5
+
9
6
  const app = express();
10
7
 
11
8
  var jsonParser = bodyParser.json()
@@ -31,6 +28,8 @@ app.all("/api/dirlist",(req,res)=>{
31
28
  })
32
29
  //获取tmui版本
33
30
  app.post("/api/cehckTmuiVer",async (req,res)=>{
31
+ const fetch = (await Fetch).default;
32
+
34
33
  setResHeader(res)
35
34
  let type = req.body?.type??'uniapp'
36
35
 
@@ -42,6 +41,8 @@ app.post("/api/cehckTmuiVer",async (req,res)=>{
42
41
  })
43
42
 
44
43
  app.post("/api/checkUniappVer",async (req,res)=>{
44
+ const fetch = (await Fetch).default;
45
+
45
46
  setResHeader(res)
46
47
  // https://registry.npmjs.org/@dcloudio/uni-app
47
48
  let resdata = await fetch(`https://mirrors.huaweicloud.com/repository/npm/@dcloudio/uni-app`,{method:'GET',headers:{'Content-Type':'text/plan'}})
@@ -74,12 +75,17 @@ app.post("/api/checkUniappVer",async (req,res)=>{
74
75
 
75
76
 
76
77
 
77
- export const createNet = ()=>{
78
+ const createNet = async ()=>{
79
+ const open = (await Open).default;
80
+
78
81
  app.listen(6170,()=>{
79
82
  open('http://localhost:6170')
80
83
  })
81
84
  }
82
85
 
86
+ module.exports = {
87
+ createNet
88
+ }
83
89
 
84
90
 
85
91
  // open('http://localhost:6170')
@@ -1,13 +1,9 @@
1
- import path from "path"
2
- import fs from "fs"
3
-
4
- import globalDirectories from "global-dirs"
5
- import {
6
- getJsonDir
7
- } from "./dirTool.js"
1
+ const path = require("path")
2
+ const globalDirectories = require("global-dirs")
3
+ const {getJsonDir} = require("./dirTool.js")
8
4
 
9
5
  /**读取项目目录 */
10
- export async function selectedDir(cb, end, pathStr) {
6
+ async function selectedDir(cb, end, pathStr) {
11
7
  try {
12
8
  let dirpath = globalDirectories.npm.prefix
13
9
  if (pathStr) {
@@ -26,3 +22,7 @@ export async function selectedDir(cb, end, pathStr) {
26
22
  }
27
23
 
28
24
 
25
+ module.exports = {
26
+ selectedDir
27
+ }
28
+
package/bin/tmui.js CHANGED
@@ -1,10 +1,11 @@
1
- import { Chalk } from "chalk";
2
- import figlet from "figlet"
3
- import { createNet } from "./net.js";
4
- import "./hooks.js";
1
+ const figlet = require("figlet")
2
+ const chalks = import("chalk")
3
+ const {createNet} = require("./net.js")
4
+ require("./hooks.js")
5
5
 
6
- let chalk = new Chalk()
7
- const main = ()=>{
6
+ const main = async ()=>{
7
+ const chalk = (await chalks).default;
8
+
8
9
  figlet('TMUI for UniApp',function(err,d){
9
10
  if(err){
10
11
  console.log(chalk.red(err))
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "tmui-cli",
3
- "version": "1.1.8",
4
- "type": "module",
3
+ "version": "1.1.9",
4
+ "type": "commonjs",
5
5
  "description": "tmui2.0,3.0,4.0x,3.2",
6
- "main": "/bin/tmui.js",
6
+ "main": "./bin/tmui.js",
7
7
  "scripts": {
8
- "dev": "node ./bin/tmui.js"
8
+ "dev": "node ./bin/tmui.js",
9
+ "test": "node ./dist/tmui.js",
10
+ "build": "webpack --mode production"
9
11
  },
10
12
  "keywords": [
11
13
  "tmui"
@@ -13,6 +15,8 @@
13
15
  "author": "tmzdy",
14
16
  "license": "MIT",
15
17
  "dependencies": {
18
+ "@babel/runtime": "^7.25.7",
19
+ "babel-polyfill": "^6.26.0",
16
20
  "body-parser": "^1.20.3",
17
21
  "bufferhelper": "^0.2.1",
18
22
  "chalk": "^5.3.0",
@@ -27,5 +31,16 @@
27
31
  "open": "^10.1.0",
28
32
  "ps-tree": "^1.2.0",
29
33
  "ws": "^8.18.0"
34
+ },
35
+ "devDependencies": {
36
+ "@babel/core": "^7.25.8",
37
+ "@babel/plugin-transform-modules-commonjs": "^7.25.7",
38
+ "@babel/plugin-transform-runtime": "^7.25.7",
39
+ "@babel/preset-env": "^7.25.8",
40
+ "babel-core": "^6.26.3",
41
+ "babel-loader": "^9.2.1",
42
+ "webpack": "^5.95.0",
43
+ "webpack-cli": "^5.1.4",
44
+ "webpack-node-externals": "^3.0.0"
30
45
  }
31
46
  }
@@ -0,0 +1,17 @@
1
+ const path = require("path");
2
+ const nodeExternals = require('webpack-node-externals');
3
+ module.exports = {
4
+ entry: './bin/tmui.js',
5
+ output: {
6
+ path: path.resolve(__dirname, 'dist'),
7
+ filename: 'tmui.js',
8
+ },
9
+
10
+ resolve: {
11
+ extensions: ['.js'], // 解析扩展名
12
+ },
13
+ target: 'node',
14
+ externals: [
15
+ nodeExternals()
16
+ ],
17
+ }