yakuza0 2.22.6 → 2.22.7-beta.0
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/nuxt/build/babel.js +12 -0
- package/nuxt/build/index.js +18 -1
- package/nuxt/build/replace.js +158 -0
- package/package.json +2 -1
package/nuxt/build/babel.js
CHANGED
|
@@ -84,6 +84,18 @@ var babelConfFn = exports.babelConfFn = function babelConfFn(nuxtConf) {
|
|
|
84
84
|
antdModule = [["import", _conf]];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
// let replaceRules = []
|
|
88
|
+
// if (yConf.security.isStupid) {
|
|
89
|
+
// replaceRules = [
|
|
90
|
+
// {
|
|
91
|
+
// // test: /\.(js)$/,
|
|
92
|
+
// test: /\.(json)$/,
|
|
93
|
+
// "search": /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/igm,
|
|
94
|
+
// "replace": "",
|
|
95
|
+
// },
|
|
96
|
+
// ];
|
|
97
|
+
// }
|
|
98
|
+
|
|
87
99
|
return (0, _extends3.default)({}, nuxtConf.build.babel, {
|
|
88
100
|
presets: function presets(_ref) {
|
|
89
101
|
var envName = _ref.envName;
|
package/nuxt/build/index.js
CHANGED
|
@@ -36,6 +36,10 @@ var _eslint2 = _interopRequireDefault(_eslint);
|
|
|
36
36
|
|
|
37
37
|
var _babel = require('./babel');
|
|
38
38
|
|
|
39
|
+
var _replace = require('./replace');
|
|
40
|
+
|
|
41
|
+
var _replace2 = _interopRequireDefault(_replace);
|
|
42
|
+
|
|
39
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
44
|
|
|
41
45
|
var customExtend = function customExtend(_ref) {
|
|
@@ -76,6 +80,18 @@ exports.default = function (config) {
|
|
|
76
80
|
|
|
77
81
|
var extendFn = function extendFn(conf, ctx) {};
|
|
78
82
|
|
|
83
|
+
var replaceRules = [];
|
|
84
|
+
|
|
85
|
+
if (!_config2.default.dev && _config2.default.security.isStupid && (nuxtConf.build && nuxtConf.build.replace && nuxtConf.build.replace.enable) !== false) {
|
|
86
|
+
replaceRules = [{
|
|
87
|
+
test: /package.json/,
|
|
88
|
+
rules: [{
|
|
89
|
+
search: /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/ig,
|
|
90
|
+
replace: ''
|
|
91
|
+
}]
|
|
92
|
+
}];
|
|
93
|
+
}
|
|
94
|
+
|
|
79
95
|
config.build = (0, _extends3.default)({}, config.build, {
|
|
80
96
|
analyze: nuxtConf.build.analyze,
|
|
81
97
|
babel: (0, _babel.babelConfFn)(nuxtConf),
|
|
@@ -89,7 +105,8 @@ exports.default = function (config) {
|
|
|
89
105
|
less: (0, _extends3.default)({
|
|
90
106
|
javascriptEnabled: true
|
|
91
107
|
}, config.build && config.build.loaders && config.build.loaders.less)
|
|
92
|
-
})
|
|
108
|
+
}),
|
|
109
|
+
plugins: [new _replace2.default([].concat((0, _toConsumableArray3.default)(replaceRules), (0, _toConsumableArray3.default)(nuxtConf.build && nuxtConf.build.replace && nuxtConf.build.replace.rules || [])))]
|
|
93
110
|
});
|
|
94
111
|
|
|
95
112
|
// config.build.extractCSS = true;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
|
|
6
|
+
function getAllFiles(root) {
|
|
7
|
+
var res = [],
|
|
8
|
+
files = fs.readdirSync(root);
|
|
9
|
+
files.forEach(function (file) {
|
|
10
|
+
var pathname = root + '/' + file,
|
|
11
|
+
stat = fs.lstatSync(pathname);
|
|
12
|
+
|
|
13
|
+
if (!stat.isDirectory()) {
|
|
14
|
+
res.push(pathname);
|
|
15
|
+
} else {
|
|
16
|
+
res = res.concat(getAllFiles(pathname));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function replace(file, rules) {
|
|
23
|
+
var src = path.resolve(file);
|
|
24
|
+
var template = fs.readFileSync(src, 'utf8');
|
|
25
|
+
|
|
26
|
+
template = rules.reduce(function (template, rule) {
|
|
27
|
+
return template.replace(rule.search, typeof rule.replace === 'string' ? rule.replace : rule.replace.bind(global));
|
|
28
|
+
}, template);
|
|
29
|
+
|
|
30
|
+
fs.writeFileSync(src, template);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function ReplaceInFilePlugin() {
|
|
34
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
35
|
+
|
|
36
|
+
this.options = options;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
ReplaceInFilePlugin.prototype.apply = function (compiler) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
|
|
42
|
+
var root = compiler.options.context;
|
|
43
|
+
var done = function done(statsData) {
|
|
44
|
+
if (statsData.hasErrors()) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
_this.options.forEach(function (option) {
|
|
48
|
+
var dir = option.dir || root;
|
|
49
|
+
var files = option.files;
|
|
50
|
+
|
|
51
|
+
if (option.files) {
|
|
52
|
+
var _files = option.files;
|
|
53
|
+
if (Array.isArray(_files) && _files.length) {
|
|
54
|
+
_files.forEach(function (file) {
|
|
55
|
+
replace(path.resolve(dir, file), option.rules);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
} else if (option.test) {
|
|
59
|
+
var test = option.test;
|
|
60
|
+
var testArray = Array.isArray(test) ? test : [test];
|
|
61
|
+
var _files2 = getAllFiles(dir);
|
|
62
|
+
|
|
63
|
+
_files2.forEach(function (file) {
|
|
64
|
+
var match = testArray.some(function (test, index, array) {
|
|
65
|
+
return test.test(file);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (!match) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
replace(file, option.rules);
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
var _files3 = getAllFiles(dir);
|
|
76
|
+
_files3.forEach(function (file) {
|
|
77
|
+
replace(file, option.rules);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (compiler.hooks) {
|
|
84
|
+
var plugin = {
|
|
85
|
+
name: "ReplaceInFilePlugin"
|
|
86
|
+
};
|
|
87
|
+
compiler.hooks.done.tap(plugin, done);
|
|
88
|
+
} else {
|
|
89
|
+
compiler.plugin('done', done);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
module.exports = ReplaceInFilePlugin;
|
|
94
|
+
|
|
95
|
+
// import {minimatch} from 'yakuza1'
|
|
96
|
+
//
|
|
97
|
+
// function visitor(path, state) {
|
|
98
|
+
// const opts = state.opts;
|
|
99
|
+
//
|
|
100
|
+
// if (Object.keys(opts).length === 0) {
|
|
101
|
+
// return;
|
|
102
|
+
// }
|
|
103
|
+
//
|
|
104
|
+
//
|
|
105
|
+
// // if (minimatch(state.filename, "**.json")) {
|
|
106
|
+
// // console.log(state.filename, 111);
|
|
107
|
+
// // }
|
|
108
|
+
//
|
|
109
|
+
// if (typeof path.node.value === "string" && path.node.value.indexOf("fedor@indutny.com") !== -1) {
|
|
110
|
+
// console.log(state.filename, 222);
|
|
111
|
+
// }
|
|
112
|
+
// state.opts.rules.map((opt) => {
|
|
113
|
+
// if (!opt.test || (opt.test && state.filename.match(opt.test))) {
|
|
114
|
+
// const isRegex = !!(opt.search && typeof opt.search === "object");
|
|
115
|
+
// const searchTemplateStrings = !!(opt.searchTemplateStrings);
|
|
116
|
+
// const isStringLiteral = path.node.type === "StringLiteral";
|
|
117
|
+
//
|
|
118
|
+
// if (isStringLiteral) {
|
|
119
|
+
// if (isRegex && path.node.value.match(opt.search) && !path.node.value.match(/\.(css)$/)) {
|
|
120
|
+
// console.log(state.filename, path.node.value, 112);
|
|
121
|
+
// path.node.value = path.node.value.replace(opt.search, opt.replace);
|
|
122
|
+
// return;
|
|
123
|
+
// }
|
|
124
|
+
//
|
|
125
|
+
// if (path.node.value === opt.search) {
|
|
126
|
+
// path.node.value = opt.replace;
|
|
127
|
+
// }
|
|
128
|
+
//
|
|
129
|
+
// return;
|
|
130
|
+
// }
|
|
131
|
+
//
|
|
132
|
+
// if (!searchTemplateStrings) {
|
|
133
|
+
// return;
|
|
134
|
+
// }
|
|
135
|
+
//
|
|
136
|
+
// if (isRegex && path.node.value.raw.match(opt.search)) {
|
|
137
|
+
// path.node.value.raw = path.node.value.raw.replace(
|
|
138
|
+
// opt.search,
|
|
139
|
+
// opt.replace
|
|
140
|
+
// );
|
|
141
|
+
// return;
|
|
142
|
+
// }
|
|
143
|
+
//
|
|
144
|
+
// if (path.node.value.raw === opt.search) {
|
|
145
|
+
// path.node.value.raw = opt.replace;
|
|
146
|
+
// }
|
|
147
|
+
// }
|
|
148
|
+
// });
|
|
149
|
+
// }
|
|
150
|
+
//
|
|
151
|
+
// module.exports = () => {
|
|
152
|
+
// return {
|
|
153
|
+
// visitor: {
|
|
154
|
+
// StringLiteral: visitor,
|
|
155
|
+
// TemplateElement: visitor,
|
|
156
|
+
// },
|
|
157
|
+
// };
|
|
158
|
+
// };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yakuza0",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.7-beta.0",
|
|
4
4
|
"description": "yakuza0 with nuxt",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"postcss-loader": "^4.3.0",
|
|
84
84
|
"postcss-url": "^10.1.3",
|
|
85
85
|
"react-dev-utils": "^11.0.4",
|
|
86
|
+
"replace-in-file-webpack-plugin": "^1.0.6",
|
|
86
87
|
"require-from-string": "^2.0.2",
|
|
87
88
|
"rimraf": "^2.6.3",
|
|
88
89
|
"sass": "^1.43.4",
|