Socket
Socket
Sign inDemoInstall

merge-umi-mock-data

Package Overview
Dependencies
453
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 2.0.6

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="2.0.6"></a>
## [2.0.6](https://github.com/chenshuai2144/merge-umi-mock-data/compare/v1.0.4...v2.0.6) (2019-05-24)
### Bug Fixes
* **core:** add backward slashes for win separators ([ce6ce67](https://github.com/chenshuai2144/merge-umi-mock-data/commit/ce6ce67))
<a name="1.0.4"></a>

@@ -7,0 +17,0 @@ ## [1.0.4](https://github.com/chenshuai2144/merge-umi-mock-data/compare/v1.0.3...v1.0.4) (2019-01-08)

66

index.js

@@ -5,9 +5,26 @@ const rollup = require("rollup");

const babel = require("rollup-plugin-babel");
const builtins = require("rollup-plugin-node-builtins");
const glob = require("glob");
const path = require("path");
const fs = require("fs");
const slash = require("slash2");
const allMock = path.join(__dirname, "./allMock.js");
const extensions = [".js", ".jsx", ".ts", ".tsx"];
const firstUpperCase = pathString => {
return pathString
.replace(".", "")
.split(/\/|\-/)
.map(s => s.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase()))
.filter(s => s)
.join("");
};
const getArrayLastTwo = fileNameArray => {
const nameArray = [];
nameArray.push(fileNameArray.pop());
nameArray.push(fileNameArray.pop());
return firstUpperCase(nameArray.join("/"));
};
const allMock = path.join(__dirname, "./allMock.ts");
const inputOptions = {

@@ -17,3 +34,2 @@ input: allMock,

plugins: [
builtins(),
json({

@@ -24,15 +40,5 @@ preferConst: true, // Default: false

babel({
extensions,
babelrc: false,
runtimeHelpers: true,
presets: [
[
"@babel/env",
{
targets: {
node: "6.11.5"
},
modules: false
}
]
]
presets: ["@babel/env", "@babel/preset-typescript"]
})

@@ -50,5 +56,12 @@ ]

mockFiles.forEach(filePath => {
const fileName = filePath.replace(".js", "");
const fileName = getArrayLastTwo(
filePath
.replace(".ts", "")
.replace("_", "")
.split("/")
);
importString.push(
`import ${fileName} from "${path.join(mockPath, filePath).replace(/\\/g,'\\\\')}";`
`import ${fileName} from "${slash(
path.join(mockPath, filePath.replace(".ts", ""))
)}";`
);

@@ -58,14 +71,20 @@ dataString.push(`...${fileName}`);

return `
${importString.join("\n")}
${importString.join("\n")}
const data = {${dataString.join(",")}};
const data = {${dataString.join(",")}};
export default data;
`;
export default data;
`;
};
async function build(mockPath, outputfile) {
const mockFiles = glob.sync("**/*.js", {
let mockFiles = glob.sync("**/*.ts", {
cwd: mockPath
});
mockFiles = mockFiles.concat(
glob.sync("../src/**/**/_mock.ts", {
cwd: mockPath,
ignore: "* node_modules"
})
);
console.log("get files: " + chalk.green(mockFiles.join(", ")));

@@ -82,5 +101,4 @@ const allMockText = importMockFiles(mockFiles, mockPath);

console.log(chalk.yellow("-".repeat(80)));
console.log(chalk.blue("finsh merge file"));
console.log(chalk.blue("finish merge file"));
}
module.exports = build;
{
"name": "merge-umi-mock-data",
"version": "1.0.5",
"version": "2.0.6",
"description": "",
"main": "index.js",
"scripts": {
"release": "standard-version",
"test": "echo \"Error: no test specified\" && exit 1"
"homepage": "https://github.com/chenshuai2144/merge-umi-mock-data#readme",
"bugs": {
"url": "https://github.com/chenshuai2144/merge-umi-mock-data/issues"
},

@@ -14,20 +13,17 @@ "repository": {

},
"license": "ISC",
"author": "chenshuai",
"license": "ISC",
"bugs": {
"url": "https://github.com/chenshuai2144/merge-umi-mock-data/issues"
"main": "index.js",
"scripts": {
"release": "standard-version",
"test": "echo \"Error: no test specified\" && exit 1"
},
"homepage": "https://github.com/chenshuai2144/merge-umi-mock-data#readme",
"dependencies": {
"@babel/core": "^7.0.0-rc.2",
"@babel/plugin-transform-modules-commonjs": "^7.0.0-rc.2",
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.2.3",
"@babel/register": "^7.0.0-rc.2",
"@babel/runtime": "^7.0.0-rc.2",
"babel-plugin-add-module-exports": "^1.0.0",
"babel-plugin-dynamic-import-node-sync": "^2.0.1",
"@babel/preset-typescript": "^7.3.3",
"chalk": "^2.4.2",
"mockjs": "^1.0.1-beta3",
"moment": "^2.22.2",
"rollup": "^1.0.2",
"rollup": "^1.12.2",
"rollup-plugin-babel": "^4.2.0",

@@ -40,4 +36,6 @@ "rollup-plugin-commonjs": "^9.2.0",

"rollup-plugin-replace": "^2.0.0",
"slash2": "^2.0.0",
"standard-version": "^4.4.0"
}
},
"devDependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc