maishu-admin-scaffold
Advanced tools
Comparing version 1.5.0 to 1.7.0
@@ -11,4 +11,4 @@ { | ||
"name": "启动程序", | ||
// "program": "${workspaceRoot}/node_modules/maishu-node-mvc/cli/mvc.js", | ||
"program": "${workspaceRoot}/node_modules/maishu-node-mvc/cli/static.js", | ||
"program": "${workspaceRoot}/node_modules/maishu-node-mvc/cli/mvc.js", | ||
// "program": "${workspaceRoot}/node_modules/maishu-node-mvc/cli/static.js", | ||
"outFiles": [], | ||
@@ -15,0 +15,0 @@ "cwd": "${workspaceFolder}/demo", |
@@ -1,4 +0,4 @@ | ||
const { getVirtualPaths } = require("../index"); | ||
const { sourceVirtualPaths } = require("../index"); | ||
const path = require("path"); | ||
let virutalPaths = getVirtualPaths(null, __dirname); | ||
let virutalPaths = sourceVirtualPaths(__dirname); | ||
virutalPaths["node_modules"] = path.join(__dirname, "../node_modules"); | ||
@@ -5,0 +5,0 @@ console.log(virutalPaths); |
@@ -11,3 +11,8 @@ "use strict"; | ||
} | ||
notAbsolutePath(path) { | ||
let msg = `Path '${path}' is not absolute path.`; | ||
let error = new Error(msg); | ||
return error; | ||
} | ||
} | ||
exports.errors = new Errors(); |
@@ -9,4 +9,9 @@ import { Errors as BaseErrors } from "maishu-toolkit"; | ||
} | ||
notAbsolutePath(path: string) { | ||
let msg = `Path '${path}' is not absolute path.`; | ||
let error = new Error(msg); | ||
return error; | ||
} | ||
} | ||
export let errors = new Errors(); |
42
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getVirtualPaths = void 0; | ||
exports.sourceVirtualPaths = exports.getVirtualPaths = void 0; | ||
const fs = require("fs"); | ||
@@ -9,2 +9,3 @@ const path = require("path"); | ||
const sc = require("maishu-chitu-scaffold"); | ||
const maishu_node_mvc_1 = require("maishu-node-mvc"); | ||
/** @param {string} [basePath] */ | ||
@@ -32,2 +33,7 @@ function getVirtualPaths(basePath, targetPath) { | ||
exports.getVirtualPaths = getVirtualPaths; | ||
/** | ||
* 获取指定文件夹的文件相对路径 | ||
* @param dir 指定的文件夹 | ||
* @returns 文件的相对路径 | ||
*/ | ||
function getFilePaths(dir) { | ||
@@ -38,3 +44,3 @@ if (path.isAbsolute(dir) == false) | ||
let stack = new Array(); | ||
stack.push(""); | ||
stack.push("/"); | ||
while (true) { | ||
@@ -44,12 +50,15 @@ let relativePath = stack.pop(); | ||
break; | ||
let p = path.join(dir, relativePath); | ||
let p = maishu_toolkit_1.pathConcat(dir, relativePath); | ||
let names = fs.readdirSync(p); | ||
for (let i = 0; i < names.length; i++) { | ||
let childPhysicalPath = path.join(p, names[i]); | ||
if (fs.statSync(childPhysicalPath).isFile()) { | ||
let childPhysicalPath = maishu_toolkit_1.pathConcat(p, names[i]); | ||
let childRelativePath = maishu_toolkit_1.pathConcat(relativePath, names[i]); | ||
let state = fs.statSync(childPhysicalPath); | ||
if (state.isDirectory()) { | ||
stack.push(childRelativePath); | ||
continue; | ||
} | ||
if (state.isFile()) { | ||
r[maishu_toolkit_1.pathConcat(relativePath, names[i])] = childPhysicalPath; | ||
} | ||
else { | ||
stack.push(maishu_toolkit_1.pathConcat(relativePath, names[i])); | ||
} | ||
} | ||
@@ -59,1 +68,18 @@ } | ||
} | ||
function sourceVirtualPaths(rootDirectory) { | ||
let root = typeof rootDirectory == "string" ? new maishu_node_mvc_1.VirtualDirectory(rootDirectory) : rootDirectory; | ||
let ctVirtualFiles = sc.sourceVirtualPaths(__dirname); | ||
let staticDir = maishu_toolkit_1.pathConcat(__dirname, "static"); | ||
let staticRelativeFiles = getFilePaths(staticDir); | ||
let items = Object.getOwnPropertyNames(staticRelativeFiles) | ||
.map(o => ({ relativePath: maishu_toolkit_1.pathConcat("static", o), physicalPath: staticRelativeFiles[o] })); | ||
let virtualFiles = {}; | ||
for (let i = 0; i < items.length; i++) { | ||
if (root.findFile(items[i].relativePath)) | ||
continue; | ||
virtualFiles[items[i].relativePath] = items[i].physicalPath; | ||
} | ||
virtualFiles = Object.assign({}, ctVirtualFiles, virtualFiles); | ||
return virtualFiles; | ||
} | ||
exports.sourceVirtualPaths = sourceVirtualPaths; |
49
index.ts
@@ -6,2 +6,3 @@ import * as fs from "fs"; | ||
import * as sc from "maishu-chitu-scaffold"; | ||
import { VirtualDirectory } from "maishu-node-mvc"; | ||
@@ -32,2 +33,7 @@ /** @param {string} [basePath] */ | ||
/** | ||
* 获取指定文件夹的文件相对路径 | ||
* @param dir 指定的文件夹 | ||
* @returns 文件的相对路径 | ||
*/ | ||
function getFilePaths(dir: string): { [key: string]: string } { | ||
@@ -39,3 +45,3 @@ if (path.isAbsolute(dir) == false) | ||
let stack = new Array<string>(); | ||
stack.push(""); | ||
stack.push("/"); | ||
@@ -47,12 +53,17 @@ while (true) { | ||
let p = path.join(dir, relativePath); | ||
let p = pathConcat(dir, relativePath); | ||
let names = fs.readdirSync(p); | ||
for (let i = 0; i < names.length; i++) { | ||
let childPhysicalPath = path.join(p, names[i]); | ||
if (fs.statSync(childPhysicalPath).isFile()) { | ||
let childPhysicalPath = pathConcat(p, names[i]); | ||
let childRelativePath = pathConcat(relativePath, names[i]); | ||
let state = fs.statSync(childPhysicalPath); | ||
if (state.isDirectory()) { | ||
stack.push(childRelativePath); | ||
continue; | ||
} | ||
if (state.isFile()) { | ||
r[pathConcat(relativePath, names[i])] = childPhysicalPath; | ||
} | ||
else { | ||
stack.push(pathConcat(relativePath, names[i])); | ||
} | ||
} | ||
@@ -64,2 +75,26 @@ } | ||
export function sourceVirtualPaths(rootDirectory: string | VirtualDirectory) { | ||
let root = typeof rootDirectory == "string" ? new VirtualDirectory(rootDirectory) : rootDirectory; | ||
let ctVirtualFiles = sc.sourceVirtualPaths(__dirname); | ||
let staticDir = pathConcat(__dirname, "static"); | ||
let staticRelativeFiles = getFilePaths(staticDir); | ||
let items = Object.getOwnPropertyNames(staticRelativeFiles) | ||
.map(o => ({ relativePath: pathConcat("static", o), physicalPath: staticRelativeFiles[o] })); | ||
let virtualFiles: { [key: string]: string } = {}; | ||
for (let i = 0; i < items.length; i++) { | ||
if (root.findFile(items[i].relativePath)) | ||
continue; | ||
virtualFiles[items[i].relativePath] = items[i].physicalPath; | ||
} | ||
virtualFiles = Object.assign({}, ctVirtualFiles, virtualFiles); | ||
return virtualFiles; | ||
} | ||
{ | ||
"dependencies": { | ||
"font-awesome": "^4.7.0", | ||
"maishu-chitu-react": "^1.27.0", | ||
"maishu-chitu-scaffold": "^1.13.0", | ||
"maishu-chitu": "^3.31.0", | ||
"maishu-chitu-react": "^1.30.0", | ||
"maishu-chitu-scaffold": "^1.15.0", | ||
"maishu-data-page": "^1.0.1", | ||
"maishu-dilu": "^1.9.1", | ||
@@ -23,2 +25,3 @@ "maishu-dilu-react": "^1.4.0", | ||
"@babel/preset-env": "^7.4.4", | ||
"@types/babel__core": "^7.1.14", | ||
"@types/mocha": "^8.2.1", | ||
@@ -28,3 +31,3 @@ "@types/node": "^14.14.30", | ||
"@types/react-dom": "^17.0.1", | ||
"maishu-node-mvc": "^2.17.0", | ||
"maishu-node-mvc": "^2.18.4", | ||
"mocha": "^8.3.0", | ||
@@ -34,3 +37,3 @@ "node-sass": "^5.0.0" | ||
"name": "maishu-admin-scaffold", | ||
"version": "1.5.0" | ||
"version": "1.7.0" | ||
} |
@@ -6,2 +6,3 @@ exports["react"] = require("react"); | ||
exports["maishu-chitu-service"] = require("maishu-chitu-service"); | ||
exports["maishu-data-page"] = require("maishu-data-page"); | ||
exports["maishu-toolkit"] = require("maishu-toolkit"); | ||
@@ -13,2 +14,2 @@ exports["maishu-ui-toolkit"] = require("maishu-ui-toolkit"); | ||
exports["text"] = require("maishu-requirejs-plugins/lib/text"); | ||
exports["json"] = require("maishu-requirejs-plugins/src/json"); |
Sorry, the diff of this file is not supported yet
929304
10086
12
16
+ Addedmaishu-chitu@^3.31.0
+ Addedmaishu-data-page@^1.0.1
+ Addedbootstrap-datepicker@1.10.0(transitive)
+ Addedjquery@3.7.1(transitive)
+ Addedmaishu-data-page@1.3.4(transitive)
+ Addedmaishu-wuzhui@1.21.18(transitive)
+ Addedmaishu-wuzhui-helper@1.13.0(transitive)
Updatedmaishu-chitu-react@^1.30.0