zero-ai 0.3.25
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/CNAME +1 -0
- package/README.md +54 -0
- package/SUMMARY.md +15 -0
- package/_config.yml +1 -0
- package/_layouts/default.html +60 -0
- package/_sass/jekyll-theme-dinky.scss +440 -0
- package/_sass/rouge-github.scss +209 -0
- package/assets/css/style.scss +4 -0
- package/assets/images/arrow-down.png +0 -0
- package/assets/images/octocat-small.png +0 -0
- package/assets/js/scale.fix.js +20 -0
- package/configs/sorts.json +38 -0
- package/document/doc-config/jsdoc.json +89 -0
- package/document/doc-config/third-part/esdoc.json +9 -0
- package/document/doc-config/third-part/yuidoc-example.json +23 -0
- package/document/doc-config/third-part/yuidoc.json +11 -0
- package/document/doc-config/tpl/publish.js +778 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/document/doc-config/tpl/static/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/document/doc-config/tpl/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/document/doc-config/tpl/static/scripts/collapse.js +20 -0
- package/document/doc-config/tpl/static/scripts/linenumber.js +25 -0
- package/document/doc-config/tpl/static/scripts/nav.js +12 -0
- package/document/doc-config/tpl/static/scripts/polyfill.js +4 -0
- package/document/doc-config/tpl/static/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/document/doc-config/tpl/static/scripts/prettify/lang-css.js +2 -0
- package/document/doc-config/tpl/static/scripts/prettify/prettify.js +28 -0
- package/document/doc-config/tpl/static/scripts/search.js +83 -0
- package/document/doc-config/tpl/static/styles/jsdoc.css +765 -0
- package/document/doc-config/tpl/static/styles/prettify.css +79 -0
- package/document/doc-config/tpl/static/styles/zero.css +50 -0
- package/document/doc-config/tpl/tmpl/augments.tmpl +10 -0
- package/document/doc-config/tpl/tmpl/container.tmpl +197 -0
- package/document/doc-config/tpl/tmpl/details.tmpl +148 -0
- package/document/doc-config/tpl/tmpl/example.tmpl +2 -0
- package/document/doc-config/tpl/tmpl/examples.tmpl +13 -0
- package/document/doc-config/tpl/tmpl/exceptions.tmpl +32 -0
- package/document/doc-config/tpl/tmpl/layout.tmpl +98 -0
- package/document/doc-config/tpl/tmpl/mainpage.tmpl +15 -0
- package/document/doc-config/tpl/tmpl/members.tmpl +38 -0
- package/document/doc-config/tpl/tmpl/method.tmpl +138 -0
- package/document/doc-config/tpl/tmpl/modifies.tmpl +14 -0
- package/document/doc-config/tpl/tmpl/params.tmpl +132 -0
- package/document/doc-config/tpl/tmpl/properties.tmpl +107 -0
- package/document/doc-config/tpl/tmpl/returns.tmpl +19 -0
- package/document/doc-config/tpl/tmpl/source.tmpl +8 -0
- package/document/doc-config/tpl/tmpl/tutorial.tmpl +19 -0
- package/document/doc-config/tpl/tmpl/type.tmpl +7 -0
- package/document/doc-config/tpl/zero.css +0 -0
- package/document/doc-web/E.html +395 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/document/doc-web/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/document/doc-web/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/document/doc-web/index.html +262 -0
- package/document/doc-web/module-_debug.html +1104 -0
- package/document/doc-web/module-_epic.html +1631 -0
- package/document/doc-web/module-ai.html +1701 -0
- package/document/doc-web/module-aj.html +1081 -0
- package/document/doc-web/scripts/collapse.js +20 -0
- package/document/doc-web/scripts/linenumber.js +25 -0
- package/document/doc-web/scripts/nav.js +12 -0
- package/document/doc-web/scripts/polyfill.js +4 -0
- package/document/doc-web/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/document/doc-web/scripts/prettify/lang-css.js +2 -0
- package/document/doc-web/scripts/prettify/prettify.js +28 -0
- package/document/doc-web/scripts/search.js +83 -0
- package/document/doc-web/styles/jsdoc.css +765 -0
- package/document/doc-web/styles/prettify.css +79 -0
- package/document/doc-web/styles/zero.css +50 -0
- package/document/markdown/README.md +0 -0
- package/document/markdown/gong-cheng-chu-shi-hua.md +79 -0
- package/document/markdown/t0002-uuidsheng-cheng-qi.md +142 -0
- package/document/markdown/t0003-shu-ju-mo-ni-qi.md +135 -0
- package/document/markdown/t0004-zerode-fu-wu-tong-xun-fen-xi-qi.md +64 -0
- package/document/markdown/t0005-liquibaseshu-ju-zhuan-huan-qi.md +68 -0
- package/document/markdown/zt0001-pagecardchuang-jian.md +71 -0
- package/document/markdown/zt0002-formchuang-jian.md +81 -0
- package/document/markdown/zt0003-tian-jia-card-an-niu.md +115 -0
- package/document/markdown/zt0004-chu-li-modal-zhe-zhao-xiao-guo.md +105 -0
- package/document/markdown/ztgong-ju.md +0 -0
- package/install-local.sh +3 -0
- package/package.json +53 -0
- package/run-authorize.sh +32 -0
- package/run-doc.sh +16 -0
- package/run-update.sh +6 -0
- package/script/bootstrap +6 -0
- package/script/cibuild +9 -0
- package/script/release +42 -0
- package/script/validate-html +28 -0
- package/script/zrun-doc-generate.sh +18 -0
- package/script/zrun-doc-server.sh +13 -0
- package/src/ai.js +11 -0
- package/src/aj.js +11 -0
- package/src/art.js +11 -0
- package/src/cab/form/UI.js.tpl +50 -0
- package/src/cab/form/UI.json.tpl +38 -0
- package/src/cab/list/Op.js.tpl +42 -0
- package/src/cab/list/UI.Add.json.tpl +32 -0
- package/src/cab/list/UI.Edit.json.tpl +34 -0
- package/src/cab/list/UI.Filter.json.tpl +29 -0
- package/src/cab/list/UI.Form.js.tpl +64 -0
- package/src/cab/list/UI.js.tpl +49 -0
- package/src/cab/list/UI.json.tpl +208 -0
- package/src/cab/perm/falcon.app.xlsx +0 -0
- package/src/cab/perm/falcon.authority.resource.perm.xlsx +0 -0
- package/src/cab/perm/falcon.authority.resource.resource.xlsx +0 -0
- package/src/cab/perm/falcon.authority.role.action.xlsx +0 -0
- package/src/cab/perm/falcon.authority.view.xlsx +0 -0
- package/src/cab/perm/falcon.battery.module.xlsx +0 -0
- package/src/cab/perm/falcon.epic.form.xlsx +0 -0
- package/src/cab/perm/falcon.epic.integration.xlsx +0 -0
- package/src/cab/perm/falcon.epic.modeling.entity.xlsx +0 -0
- package/src/cab/perm/falcon.epic.modeling.field.xlsx +0 -0
- package/src/cab/perm/falcon.epic.modeling.global.xlsx +0 -0
- package/src/cab/perm/falcon.epic.modeling.model.xlsx +0 -0
- package/src/cab/perm/falcon.epic.page.xlsx +0 -0
- package/src/cab/perm/falcon.epic.topology.xlsx +0 -0
- package/src/cab/perm/falcon.fm.bank.xlsx +0 -0
- package/src/cab/perm/falcon.fm.bill.process.xlsx +0 -0
- package/src/cab/perm/falcon.fm.book.xlsx +0 -0
- package/src/cab/perm/falcon.fm.currency.xlsx +0 -0
- package/src/cab/perm/falcon.fm.debt.xlsx +0 -0
- package/src/cab/perm/falcon.fm.settlement.xlsx +0 -0
- package/src/cab/perm/falcon.fm.subject.xlsx +0 -0
- package/src/cab/perm/falcon.fm.term.xlsx +0 -0
- package/src/cab/perm/falcon.i.directory.xlsx +0 -0
- package/src/cab/perm/falcon.i.integration.xlsx +0 -0
- package/src/cab/perm/falcon.lbs.city.xlsx +0 -0
- package/src/cab/perm/falcon.lbs.floor.xlsx +0 -0
- package/src/cab/perm/falcon.lbs.query.xlsx +0 -0
- package/src/cab/perm/falcon.lbs.state.xlsx +0 -0
- package/src/cab/perm/falcon.lbs.tent.xlsx +0 -0
- package/src/cab/perm/falcon.login.index.xlsx +0 -0
- package/src/cab/perm/falcon.my.menu.xlsx +0 -0
- package/src/cab/perm/falcon.organization.brand.xlsx +0 -0
- package/src/cab/perm/falcon.organization.company.xlsx +0 -0
- package/src/cab/perm/falcon.organization.contract.xlsx +0 -0
- package/src/cab/perm/falcon.organization.customer.xlsx +0 -0
- package/src/cab/perm/falcon.organization.dept.team.xlsx +0 -0
- package/src/cab/perm/falcon.organization.dept.xlsx +0 -0
- package/src/cab/perm/falcon.organization.employee.identity.xlsx +0 -0
- package/src/cab/perm/falcon.organization.employee.xlsx +0 -0
- package/src/cab/perm/falcon.organization.project.xlsx +0 -0
- package/src/cab/perm/falcon.psi.pos.xlsx +0 -0
- package/src/cab/perm/falcon.psi.wh.xlsx +0 -0
- package/src/cab/perm/falcon.rbac.group.xlsx +0 -0
- package/src/cab/perm/falcon.rbac.role.xlsx +0 -0
- package/src/cab/perm/falcon.rbac.user.xlsx +0 -0
- package/src/cab/perm/falcon.system.document.xlsx +0 -0
- package/src/cab/perm/falcon.system.job.xlsx +0 -0
- package/src/cab/perm/falcon.system.report.xlsx +0 -0
- package/src/cab/perm/falcon.system.sync_log.xlsx +0 -0
- package/src/cab/perm/falcon.system.todo.xlsx +0 -0
- package/src/cab/perm/falcon.system.workflow.xlsx +0 -0
- package/src/cab/perm/falcon.ui.app.xlsx +0 -0
- package/src/cab/perm/falcon.view.personal.xlsx +0 -0
- package/src/cab/perm/falcon.x.activity.xlsx +0 -0
- package/src/cab/perm/falcon.x.attachment.xlsx +0 -0
- package/src/cab/perm/falcon.x.category.xlsx +0 -0
- package/src/cab/perm/falcon.x.integration.xlsx +0 -0
- package/src/cab/perm/falcon.x.linkage.xlsx +0 -0
- package/src/cab/perm/falcon.x.menu.xlsx +0 -0
- package/src/cab/perm/falcon.x.notice.xlsx +0 -0
- package/src/cab/perm/falcon.x.tabular.xlsx +0 -0
- package/src/cab/perm/falcon.x.tag.xlsx +0 -0
- package/src/cab/plugin/Component.java.tpl +52 -0
- package/src/cab/plugin/Cv.java.tpl +21 -0
- package/src/cab/plugin/ErrorIo.java.tpl +26 -0
- package/src/cab/plugin/In.Abstract.java.tpl +30 -0
- package/src/cab/plugin/In.java.tpl +25 -0
- package/src/cab/plugin/Io.Abstract.java.tpl +36 -0
- package/src/cab/plugin/Io.Impl.java.tpl +21 -0
- package/src/cab/plugin/Io.java.tpl +73 -0
- package/src/cab/plugin/Plugin.After.java.tpl +22 -0
- package/src/cab/plugin/Plugin.Before.java.tpl +22 -0
- package/src/cab/plugin/Refine.Log.java.tpl +47 -0
- package/src/cab/plugin/Refine.Pin.java.tpl +70 -0
- package/src/cab/plugin/Refine.java.tpl +67 -0
- package/src/cab/plugin/configuration.json.tpl +3 -0
- package/src/cab/plugin/infix.xml.tpl +22 -0
- package/src/cab/plugin/integration.json.tpl +20 -0
- package/src/cab/resource/falcon.resource.xlsx +0 -0
- package/src/cab/resource/resource.json +8 -0
- package/src/cab/resource/resource.xlsx +0 -0
- package/src/commander/ai.zero +10 -0
- package/src/commander/aj.zero +8 -0
- package/src/commander/ar.zero +4 -0
- package/src/commander/option.zero +21 -0
- package/src/commander-ai/fn.csv.js +105 -0
- package/src/commander-ai/fn.data.js +404 -0
- package/src/commander-ai/fn.init.js +106 -0
- package/src/commander-ai/fn.key.js +81 -0
- package/src/commander-ai/fn.md5.js +76 -0
- package/src/commander-ai/fn.random.js +84 -0
- package/src/commander-ai/fn.uk.js +70 -0
- package/src/commander-ai/fn.uuid.js +80 -0
- package/src/commander-ai/index.js +19 -0
- package/src/commander-aj/bundle/specification.txt +49 -0
- package/src/commander-aj/fn.i.mod.js +26 -0
- package/src/commander-aj/fn.i.resource.js +33 -0
- package/src/commander-aj/fn.j.bundle.js +51 -0
- package/src/commander-aj/fn.j.init.js +72 -0
- package/src/commander-aj/fn.j.permission.js +60 -0
- package/src/commander-aj/fn.j.plugin.js +120 -0
- package/src/commander-aj/fn.j.row.js +5 -0
- package/src/commander-aj/index.js +16 -0
- package/src/commander-ar/fn.i.complex.js +112 -0
- package/src/commander-ar/fn.i.form.js +91 -0
- package/src/commander-ar/index.js +7 -0
- package/src/epic/ai.economy.impl.fn.excel.js +128 -0
- package/src/epic/ai.economy.impl.fn.execute.js +162 -0
- package/src/epic/ai.economy.impl.fn.java.js +140 -0
- package/src/epic/ai.economy.impl.fn.json.js +23 -0
- package/src/epic/ai.economy.impl.fn.plugin.js +160 -0
- package/src/epic/ai.economy.impl.fn.react.js +219 -0
- package/src/epic/ai.export.impl.fn.parse.js +345 -0
- package/src/epic/ai.export.impl.fn.seek.js +42 -0
- package/src/epic/ai.export.interface.fn.string.js +5 -0
- package/src/epic/ai.export.interface.io.js +69 -0
- package/src/epic/ai.export.interface.util.js +17 -0
- package/src/epic/ai.path.fn.dir.operation.js +87 -0
- package/src/epic/ai.path.fn.io.command.js +43 -0
- package/src/epic/ai.path.fn.io.specification.js +59 -0
- package/src/epic/ai.path.fn.io.typed.js +63 -0
- package/src/epic/ai.path.fn.out.content.js +47 -0
- package/src/epic/ai.string.fn.str.util.js +56 -0
- package/src/epic/ai.uncork.fn.element.feature.js +52 -0
- package/src/epic/ai.uncork.fn.it.feature.js +118 -0
- package/src/epic/ai.uncork.fn.to.typed.js +74 -0
- package/src/epic/ai.under.fn.cx.evaluate.js +81 -0
- package/src/epic/ai.under.fn.fx.terminal.js +143 -0
- package/src/epic/ai.unified.fn._.logging.js +45 -0
- package/src/epic/ai.unified.fn.fn.error.code.js +114 -0
- package/src/epic/ai.unified.fn.is.decision.js +20 -0
- package/src/epic/ai.unified.fn.sorter.element.js +26 -0
- package/src/epic/index.js +216 -0
- package/src/epic/zero.__.fn.find.util.js +37 -0
- package/src/epic/zero.__.v.constant.js +5 -0
- package/test/csv.json +12 -0
- package/test/csv.zero +2 -0
- package/test/data.zero +56 -0
- package/test/key/key1.json +15 -0
- package/test/key/key2.json +12 -0
- package/test/key/key3.json +5 -0
- package/test/key.json +12 -0
- package/test/uk.json +19 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const Immutable = require('immutable');
|
|
3
|
+
const U = require('underscore');
|
|
4
|
+
const __CX = require('./ai.under.fn.cx.evaluate');
|
|
5
|
+
const __FX = require('./ai.under.fn.fx.terminal');
|
|
6
|
+
const __IT = require('./ai.uncork.fn.it.feature');
|
|
7
|
+
const __IO = require('./ai.export.interface.io');
|
|
8
|
+
const __LOG = require('./ai.unified.fn._.logging');
|
|
9
|
+
const __STR = require('./ai.export.interface.fn.string');
|
|
10
|
+
|
|
11
|
+
const _parseButtons = (value) => {
|
|
12
|
+
if (value.startsWith('(') && value.endsWith(')')) {
|
|
13
|
+
// 分组的情况
|
|
14
|
+
} else {
|
|
15
|
+
value = value.split('-');
|
|
16
|
+
const buttons = [];
|
|
17
|
+
value.forEach((eachVal) => {
|
|
18
|
+
const button = {};
|
|
19
|
+
const eachVals = eachVal.split(':');
|
|
20
|
+
button.text = eachVals[0];
|
|
21
|
+
if (eachVals[1]) {
|
|
22
|
+
button.key = `btn${__STR.strFirstUpper(eachVals[1])}`;
|
|
23
|
+
}
|
|
24
|
+
if (eachVals[2]) {
|
|
25
|
+
button.type = eachVals[2];
|
|
26
|
+
}
|
|
27
|
+
buttons.push(button);
|
|
28
|
+
});
|
|
29
|
+
return buttons;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const _parseTopbar = (key, value = "") => {
|
|
33
|
+
const textes = value.split(',');
|
|
34
|
+
const ret = {};
|
|
35
|
+
const config = {};
|
|
36
|
+
textes.forEach(text => {
|
|
37
|
+
if (0 <= text.indexOf('=')) {
|
|
38
|
+
const kv = text.split('=');
|
|
39
|
+
const key = kv[0].trim();
|
|
40
|
+
let value = kv[1].trim();
|
|
41
|
+
if ("buttons" === key) {
|
|
42
|
+
value = _parseButtons(value);
|
|
43
|
+
}
|
|
44
|
+
config[key] = value;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
ret[`_${key}`] = config;
|
|
48
|
+
return ret;
|
|
49
|
+
};
|
|
50
|
+
const _parseTabs = (key, value = "") => {
|
|
51
|
+
const textes = value.split(',');
|
|
52
|
+
const ret = {};
|
|
53
|
+
const items = [];
|
|
54
|
+
textes.forEach((each, index) => {
|
|
55
|
+
const item = {};
|
|
56
|
+
item.tab = each;
|
|
57
|
+
item.key = `tabItem${index}`;
|
|
58
|
+
items.push(item);
|
|
59
|
+
});
|
|
60
|
+
ret[`_${key}`] = {items};
|
|
61
|
+
return ret;
|
|
62
|
+
};
|
|
63
|
+
const _parseNav = (key, value = "") => {
|
|
64
|
+
const textes = value.split(',');
|
|
65
|
+
const ret = {};
|
|
66
|
+
const items = [];
|
|
67
|
+
textes.forEach(each => {
|
|
68
|
+
const item = {};
|
|
69
|
+
if (0 <= each.indexOf('-')) {
|
|
70
|
+
const meta = each.split('-');
|
|
71
|
+
item.text = meta[0];
|
|
72
|
+
item.uri = meta[1];
|
|
73
|
+
} else {
|
|
74
|
+
item.text = each;
|
|
75
|
+
}
|
|
76
|
+
items.push(item);
|
|
77
|
+
});
|
|
78
|
+
if (0 < items.length && items[0]) {
|
|
79
|
+
items[0].uri = '$MAIN$';
|
|
80
|
+
}
|
|
81
|
+
if (1 < items.length && items[items.length - 1]) {
|
|
82
|
+
items[items.length - 1].uri = '$SELF$';
|
|
83
|
+
}
|
|
84
|
+
items.forEach((item, index) => {
|
|
85
|
+
item.key = `lnkNav${index}`;
|
|
86
|
+
});
|
|
87
|
+
ret[`_${key}`] = items;
|
|
88
|
+
return ret;
|
|
89
|
+
};
|
|
90
|
+
const _parser = {
|
|
91
|
+
NAV: _parseNav,
|
|
92
|
+
TOPBAR: _parseTopbar,
|
|
93
|
+
TABS: _parseTabs
|
|
94
|
+
};
|
|
95
|
+
const _parseLine = (line = "") => {
|
|
96
|
+
// 以#号为配置项
|
|
97
|
+
if (0 <= line.indexOf('#')) {
|
|
98
|
+
const kv = line.split('#');
|
|
99
|
+
const prefix = kv[0];
|
|
100
|
+
const value = kv[1];
|
|
101
|
+
const type = prefix.toUpperCase();
|
|
102
|
+
if (_parser[type]) {
|
|
103
|
+
return _parser[type](prefix, value);
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
__LOG.warn(`不合法格式(不包含#)跳过配置行${line}`)
|
|
107
|
+
}
|
|
108
|
+
return {};
|
|
109
|
+
};
|
|
110
|
+
const parseUi = (lines = []) => {
|
|
111
|
+
const result = {};
|
|
112
|
+
lines.forEach(line => {
|
|
113
|
+
const kv = _parseLine(line);
|
|
114
|
+
Object.assign(result, kv);
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const _parseValue = (value = "") => {
|
|
120
|
+
// 是否数值
|
|
121
|
+
if (value) {
|
|
122
|
+
if ("true" === value.toString().toLowerCase()
|
|
123
|
+
|| "false" === value.toString().toLowerCase()) {
|
|
124
|
+
value = "true" === value.toString().toLowerCase();
|
|
125
|
+
} else if (value.startsWith("[")) {
|
|
126
|
+
value = JSON.parse(value);
|
|
127
|
+
} else {
|
|
128
|
+
const reg = /^([1-9]\d*|-[1-9]\d*)$/;
|
|
129
|
+
if (reg.test(value)) {
|
|
130
|
+
value = parseInt(value, 10);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return value;
|
|
135
|
+
};
|
|
136
|
+
const _parseExpr = (item = "") => {
|
|
137
|
+
let ret = item;
|
|
138
|
+
if (item) {
|
|
139
|
+
item = item.toString().trim();
|
|
140
|
+
if (0 < item.indexOf('=')) {
|
|
141
|
+
const kv = item.split('=');
|
|
142
|
+
kv[1] = _parseValue(kv[1]);
|
|
143
|
+
ret = [kv[0], kv[1]];
|
|
144
|
+
} else {
|
|
145
|
+
ret = [item, item];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return ret;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const _parseRel = (lines = []) => {
|
|
152
|
+
const array = [];
|
|
153
|
+
lines.forEach(line => {
|
|
154
|
+
const parsed = _parseExpr(line.trim());
|
|
155
|
+
array.push(parsed);
|
|
156
|
+
});
|
|
157
|
+
return array;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const _parseOption = (item = "", name = "option") => {
|
|
161
|
+
const root = __IO.ioRoot();
|
|
162
|
+
const prop = parseZero(root + "/commander/" + name + ".zero", ["P;"]);
|
|
163
|
+
const kv = _parseExpr(item);
|
|
164
|
+
const pair = {};
|
|
165
|
+
pair[kv[0]] = kv[1];
|
|
166
|
+
if (prop[kv[0]]) pair[prop[kv[0]]] = kv[1];
|
|
167
|
+
delete pair[undefined];
|
|
168
|
+
return pair;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const _parseArray = (lines = []) => {
|
|
172
|
+
const fields = lines.shift();
|
|
173
|
+
const fieldArr = fields.split(',');
|
|
174
|
+
const result = [];
|
|
175
|
+
lines.forEach(line => {
|
|
176
|
+
const valueArr = line.toString().trim().split(',');
|
|
177
|
+
const entity = {};
|
|
178
|
+
__IT.itPair(fieldArr, valueArr, (first, second) => {
|
|
179
|
+
first = first ? first.trim() : first;
|
|
180
|
+
second = second ? second.trim() : second;
|
|
181
|
+
if (first.startsWith('option')) {
|
|
182
|
+
const optionValue = _parseOption(second);
|
|
183
|
+
if (0 < Object.keys(optionValue).length) {
|
|
184
|
+
entity[first] = optionValue;
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
entity[first] = second;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
result.push(entity);
|
|
191
|
+
});
|
|
192
|
+
return result;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const _parseProp = (lines) => {
|
|
196
|
+
const data = {};
|
|
197
|
+
lines.forEach(line => {
|
|
198
|
+
const parsed = _parseExpr(line.trim());
|
|
199
|
+
data[parsed[0]] = parsed[1];
|
|
200
|
+
});
|
|
201
|
+
return data;
|
|
202
|
+
};
|
|
203
|
+
const _parseKv = (lines = []) => {
|
|
204
|
+
let content = "";
|
|
205
|
+
lines.forEach(line => content += line);
|
|
206
|
+
const pairs = content.split(',');
|
|
207
|
+
const result = {};
|
|
208
|
+
pairs.forEach(pair => {
|
|
209
|
+
const input = pair.trim();
|
|
210
|
+
const kv = _parseExpr(input);
|
|
211
|
+
result[kv[0].trim()] = kv[1];
|
|
212
|
+
});
|
|
213
|
+
return result;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const PARSER = {
|
|
217
|
+
"P;": _parseProp, "P": _parseProp,
|
|
218
|
+
"A;": _parseArray, "A": _parseArray,
|
|
219
|
+
"KV;": _parseKv, "KV": _parseKv,
|
|
220
|
+
"UI;": parseUi, "UI": parseUi,
|
|
221
|
+
"R;": _parseRel, "R": _parseRel
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* ## `Ec.parseZero`
|
|
225
|
+
*
|
|
226
|
+
* ### 1. 基本介绍
|
|
227
|
+
*
|
|
228
|
+
* 解析路径中的特殊文件,文件后缀使用`.zero`,作为当前工具的核心配置数据,文件内容通常如下(`UTF-8`方式读取内容):
|
|
229
|
+
*
|
|
230
|
+
* ```shell
|
|
231
|
+
* PREFIX;
|
|
232
|
+
* <Content>
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* 此处`PREFIX`则是第二参数,表示不同的文件类型,不同文件类型的解析方式有所区别。
|
|
236
|
+
*
|
|
237
|
+
* ### 2. 文件类型
|
|
238
|
+
*
|
|
239
|
+
* |前缀|含义|
|
|
240
|
+
* |:---|:---|
|
|
241
|
+
* |`P;`|属性文件专用集,用于描述基础属性文件内容。|
|
|
242
|
+
* |`KV;`|`P;`的不换行模式,直接以`,`为每一个键值对的匹配项,去`\n`换行符过后统一解析,不支持`ENUM`枚举信息。|
|
|
243
|
+
* |`R;`|关系专用解析文件,可解析关系数据文件(后期可增强)。|
|
|
244
|
+
* |`A;`|命令解析专用,表格解析器,解析以`\t`为分隔符的表格,然后解析尾部`optionX`部分为配置选项。|
|
|
245
|
+
* |`UI;`|Jsx文件专用解析器,根据文件模板解析数据。|
|
|
246
|
+
* |`J;`|Java文件专用解析器,解析Java源代码文件数据专用。|
|
|
247
|
+
*
|
|
248
|
+
* @memberOf module:_epic
|
|
249
|
+
* @param {String} path 解析文件的路径
|
|
250
|
+
* @param {Array} fileTypes 文件前缀类型
|
|
251
|
+
* @returns {Any} 最终解析出来的数据内容
|
|
252
|
+
*/
|
|
253
|
+
const parseZero = (path, fileTypes = ['J;', 'P;', 'A;', 'KV;', "UI;", 'R;']) => {
|
|
254
|
+
if (fs.existsSync(path)) {
|
|
255
|
+
const content = fs.readFileSync(path, "utf-8").trim();
|
|
256
|
+
const lines = content.split(/\r?\n/g); //for darwin, it is \n; for win32, it is \r\n.
|
|
257
|
+
const fileType = lines.shift();
|
|
258
|
+
__CX.cxEnum(fileType, fileTypes);
|
|
259
|
+
const parser = PARSER[fileType];
|
|
260
|
+
__FX.fxError(!U.isFunction(parser), 10003, fileType);
|
|
261
|
+
return parser(lines);
|
|
262
|
+
} else {
|
|
263
|
+
__FX.fxError(10009, path);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* ## `Ec.parseArgs`
|
|
268
|
+
*
|
|
269
|
+
* @memberOf module:_epic
|
|
270
|
+
* @param {Number} ensure 参数允许的长度解析,如果长度不合法,则直接退出
|
|
271
|
+
* @returns {Object} 解析成功后的数据信息
|
|
272
|
+
*/
|
|
273
|
+
const parseArgs = (ensure) => {
|
|
274
|
+
const inputArgs = process.argv.splice(3);
|
|
275
|
+
if (ensure === inputArgs.length) {
|
|
276
|
+
const config = {};
|
|
277
|
+
let key = undefined;
|
|
278
|
+
let value = undefined;
|
|
279
|
+
for (let idx = 0; idx <= inputArgs.length; idx++) {
|
|
280
|
+
if (0 === idx % 2) {
|
|
281
|
+
key = inputArgs[idx];
|
|
282
|
+
} else {
|
|
283
|
+
value = inputArgs[idx];
|
|
284
|
+
}
|
|
285
|
+
if (key && value) {
|
|
286
|
+
config[key] = value;
|
|
287
|
+
key = undefined;
|
|
288
|
+
value = undefined;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return config;
|
|
292
|
+
} else {
|
|
293
|
+
__LOG.error(`参数丢失,期望参数: ${ensure / 2} 个.`);
|
|
294
|
+
process.exit();
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const parseInput = (required = []) => {
|
|
299
|
+
const inputArgs = process.argv.splice(3);
|
|
300
|
+
const config = {};
|
|
301
|
+
let key = undefined;
|
|
302
|
+
let value = undefined;
|
|
303
|
+
for (let idx = 0; idx <= inputArgs.length; idx++) {
|
|
304
|
+
if (0 === idx % 2) {
|
|
305
|
+
key = inputArgs[idx];
|
|
306
|
+
} else {
|
|
307
|
+
value = inputArgs[idx];
|
|
308
|
+
}
|
|
309
|
+
if (key && value) {
|
|
310
|
+
config[key] = value;
|
|
311
|
+
key = undefined;
|
|
312
|
+
value = undefined;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const $keys = Immutable.fromJS(Object.keys(config));
|
|
316
|
+
__IT.itArray(required, (each) => {
|
|
317
|
+
const checked = 1 < each.length && (!($keys.contains(each[0]) || $keys.contains(each[1])));
|
|
318
|
+
__FX.fxError(checked, 10006, each);
|
|
319
|
+
});
|
|
320
|
+
return config;
|
|
321
|
+
};
|
|
322
|
+
const parseFormat = (args = {}, pairs = []) => {
|
|
323
|
+
const actual = {};
|
|
324
|
+
pairs.forEach(item => __FX.fxContinue(U.isArray(item), () => {
|
|
325
|
+
const arg0 = item[0];
|
|
326
|
+
const arg1 = item[1];
|
|
327
|
+
let finalKey = arg0.length > arg1.length ? arg0 : arg1;
|
|
328
|
+
finalKey = finalKey.toString().replace(/-/g, '');
|
|
329
|
+
const dft = item[2];
|
|
330
|
+
__IT.itObject(args, (key, value) => __FX.fxContinue(arg0 === key || arg1 === key, () => {
|
|
331
|
+
actual[finalKey] = value;
|
|
332
|
+
}));
|
|
333
|
+
__FX.fxContinue(!args.hasOwnProperty(arg0) && !args.hasOwnProperty(arg1) && undefined !== dft, () => {
|
|
334
|
+
actual[finalKey] = dft;
|
|
335
|
+
});
|
|
336
|
+
}));
|
|
337
|
+
__LOG.info(`Zero AI 加载输入参数:\n${JSON.stringify(actual, null, 4).blue}`);
|
|
338
|
+
return actual;
|
|
339
|
+
};
|
|
340
|
+
module.exports = {
|
|
341
|
+
parseInput,
|
|
342
|
+
parseFormat,
|
|
343
|
+
parseArgs,
|
|
344
|
+
parseZero,
|
|
345
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const __IO = require('./ai.export.interface.io');
|
|
2
|
+
const Ec = require("./index");
|
|
3
|
+
|
|
4
|
+
const seekResource = (path = ".") => {
|
|
5
|
+
const parent = __IO.dirTree(path, folder => __IO.isExist(folder + "/pom.xml"));
|
|
6
|
+
// 查找最近的项目目录资源信息
|
|
7
|
+
let found;
|
|
8
|
+
parent.forEach(item => {
|
|
9
|
+
if (found) {
|
|
10
|
+
if (item.length > found.length) {
|
|
11
|
+
found = item;
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
found = item;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
// 追加 src/main/resources/
|
|
18
|
+
return `${found}/src/main/resources`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const seekChildren = (path = ".", filterFn) => {
|
|
22
|
+
const children = __IO.dirChildren(path, true);
|
|
23
|
+
const fileArray = [];
|
|
24
|
+
children.forEach(child => {
|
|
25
|
+
const files = __IO.ioFiles(child);
|
|
26
|
+
files.forEach(file => {
|
|
27
|
+
if (__IO.isFunction(filterFn)) {
|
|
28
|
+
if (filterFn(file.file)) {
|
|
29
|
+
fileArray.push(file.path.replace(path, ""));
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
fileArray.push(file.path.replace(path, ""));
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
return fileArray;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
seekResource,
|
|
41
|
+
seekChildren,
|
|
42
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const __IS = require('./ai.unified.fn.is.decision');
|
|
2
|
+
const __TO = require('./ai.uncork.fn.to.typed');
|
|
3
|
+
const __OUT = require("./ai.path.fn.out.content");
|
|
4
|
+
|
|
5
|
+
const __IO_CMD = require("./ai.path.fn.io.command");
|
|
6
|
+
const __IO_SPEC = require('./ai.path.fn.io.specification');
|
|
7
|
+
const __IO_TYPED = require('./ai.path.fn.io.typed');
|
|
8
|
+
|
|
9
|
+
const __DIR = require("./ai.path.fn.dir.operation");
|
|
10
|
+
|
|
11
|
+
const __IO = {
|
|
12
|
+
...__IO_CMD,
|
|
13
|
+
...__IO_TYPED,
|
|
14
|
+
...__IO_SPEC,
|
|
15
|
+
}
|
|
16
|
+
module.exports = {
|
|
17
|
+
|
|
18
|
+
// interface.
|
|
19
|
+
/*
|
|
20
|
+
dirChildren,
|
|
21
|
+
dirParent,
|
|
22
|
+
dirTree,
|
|
23
|
+
dirCreate,
|
|
24
|
+
dirResolve,
|
|
25
|
+
*/
|
|
26
|
+
...__DIR,
|
|
27
|
+
// interface.
|
|
28
|
+
/*
|
|
29
|
+
ioCopy,
|
|
30
|
+
ioDelete,
|
|
31
|
+
|
|
32
|
+
ioJArray,
|
|
33
|
+
ioJObject,
|
|
34
|
+
ioString,
|
|
35
|
+
ioStream,
|
|
36
|
+
ioCsv,
|
|
37
|
+
ioProp,
|
|
38
|
+
ioFiles,
|
|
39
|
+
|
|
40
|
+
ioName,
|
|
41
|
+
ioRoot,
|
|
42
|
+
ioDataA,
|
|
43
|
+
ioSwitch,
|
|
44
|
+
*/
|
|
45
|
+
...__IO,
|
|
46
|
+
|
|
47
|
+
// interface.
|
|
48
|
+
/*
|
|
49
|
+
outJson,
|
|
50
|
+
outString,
|
|
51
|
+
outCopy,
|
|
52
|
+
*/
|
|
53
|
+
...__OUT,
|
|
54
|
+
// interface.
|
|
55
|
+
/*
|
|
56
|
+
toTable,
|
|
57
|
+
toJObject,
|
|
58
|
+
toJArray,
|
|
59
|
+
toCsv,
|
|
60
|
+
*/
|
|
61
|
+
...__TO,
|
|
62
|
+
// interface.
|
|
63
|
+
/*
|
|
64
|
+
isFile,
|
|
65
|
+
isDirectory,
|
|
66
|
+
isExist
|
|
67
|
+
*/
|
|
68
|
+
...__IS,
|
|
69
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const func_uncork_element_feature = require('./ai.uncork.fn.element.feature');
|
|
2
|
+
const func_unbind_it_feature = require('./ai.uncork.fn.it.feature');
|
|
3
|
+
const func_under_cx_evaluate = require('./ai.under.fn.cx.evaluate');
|
|
4
|
+
const func_under_fx_terminal = require('./ai.under.fn.fx.terminal');
|
|
5
|
+
const func_under___logging = require('./ai.unified.fn._.logging');
|
|
6
|
+
const func_unified_sorter_element = require("./ai.unified.fn.sorter.element");
|
|
7
|
+
const Immutable = require("immutable");
|
|
8
|
+
module.exports = {
|
|
9
|
+
...func_uncork_element_feature,
|
|
10
|
+
...func_unbind_it_feature,
|
|
11
|
+
...func_under_cx_evaluate,
|
|
12
|
+
...func_under_fx_terminal,
|
|
13
|
+
...func_under___logging,
|
|
14
|
+
...func_unified_sorter_element,
|
|
15
|
+
// clone method
|
|
16
|
+
clone: input => Immutable.fromJS(input).toJS(),
|
|
17
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const __FX = require("./ai.under.fn.fx.terminal");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const U = require("underscore");
|
|
4
|
+
const __LOG = require("./ai.unified.fn._.logging");
|
|
5
|
+
const __V = require("./zero.__.v.constant");
|
|
6
|
+
const __U = require("./zero.__.fn.find.util");
|
|
7
|
+
const __IS = require("./ai.unified.fn.is.decision");
|
|
8
|
+
const __IO = require("./ai.path.fn.io.specification");
|
|
9
|
+
const dirResolve = (path = "") => {
|
|
10
|
+
let result = path.trim();
|
|
11
|
+
if (result.endsWith(__V.FILE_DELIMITER)) {
|
|
12
|
+
result = result.substring(0, result.length - 1);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
const dirTree = (pathDir = ".", pathFilterFn) => {
|
|
17
|
+
// 截取当前运行目录
|
|
18
|
+
const pathStart = __IO.ioSwitch(pathDir);
|
|
19
|
+
// 往上查找项目根目录
|
|
20
|
+
const pathArr = pathStart.split(__V.FILE_DELIMITER);
|
|
21
|
+
const pathIt = [];
|
|
22
|
+
while (0 < pathArr.length) {
|
|
23
|
+
const folder = pathArr.join("/");
|
|
24
|
+
if ('' !== folder) {
|
|
25
|
+
if (U.isFunction(pathFilterFn)) {
|
|
26
|
+
if (pathFilterFn(folder)) {
|
|
27
|
+
pathIt.push(folder);
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
pathIt.push(folder);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
pathArr.pop();
|
|
34
|
+
}
|
|
35
|
+
return pathIt;
|
|
36
|
+
}
|
|
37
|
+
const dirParent = (path, includeCurrent = false) => {
|
|
38
|
+
let result = [];
|
|
39
|
+
if (includeCurrent) {
|
|
40
|
+
result.push(path);
|
|
41
|
+
}
|
|
42
|
+
__FX.fxContinue(fs.existsSync(path), () => {
|
|
43
|
+
let parent = dirResolve(path);
|
|
44
|
+
parent = parent.substring(0, parent.lastIndexOf(__V.FILE_DELIMITER));
|
|
45
|
+
result.push(parent);
|
|
46
|
+
result = result.concat(dirParent(parent, false));
|
|
47
|
+
});
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const dirChildren = (path, includeCurrent = true) => {
|
|
52
|
+
let result = [];
|
|
53
|
+
if (includeCurrent) {
|
|
54
|
+
result.push(path);
|
|
55
|
+
}
|
|
56
|
+
__FX.fxContinue(fs.existsSync(path), () => {
|
|
57
|
+
const folders = fs.readdirSync(path);
|
|
58
|
+
const directory = dirResolve(path) + __V.FILE_DELIMITER;
|
|
59
|
+
folders.forEach(item => __FX.fxContinue(!item.startsWith('.'), () => {
|
|
60
|
+
const absolute = directory + item;
|
|
61
|
+
if (__IS.isDirectory(absolute)) {
|
|
62
|
+
result.push(absolute);
|
|
63
|
+
result = result.concat(dirChildren(absolute, false));
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const dirCreate = (path = "") => {
|
|
71
|
+
// TODO: Path专用
|
|
72
|
+
const folderInfo = __U.findTrace(path);
|
|
73
|
+
// 查找第一个存在的目录
|
|
74
|
+
const lefts = folderInfo.filter(item => !__IS.isExist(item)).sort((left, right) => left.length - right.length);
|
|
75
|
+
lefts.filter(item => '' !== item).forEach(left => {
|
|
76
|
+
__LOG.info("创建目录:" + left.yellow);
|
|
77
|
+
fs.mkdirSync(left);
|
|
78
|
+
});
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
81
|
+
module.exports = {
|
|
82
|
+
dirCreate,
|
|
83
|
+
dirChildren,
|
|
84
|
+
dirParent,
|
|
85
|
+
dirResolve,
|
|
86
|
+
dirTree,
|
|
87
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const __LOG = require("./ai.unified.fn._.logging");
|
|
3
|
+
const __FX = require("./ai.under.fn.fx.terminal");
|
|
4
|
+
const __IO = require('./ai.path.fn.io.typed');
|
|
5
|
+
const __IS = require("./ai.unified.fn.is.decision");
|
|
6
|
+
const __OUT = require("./ai.path.fn.out.content");
|
|
7
|
+
const __V = require("./zero.__.v.constant");
|
|
8
|
+
|
|
9
|
+
const __ioDeleteDir = (path) => {
|
|
10
|
+
if (fs.existsSync(path)) {
|
|
11
|
+
const etat = fs.statSync(path);
|
|
12
|
+
if (etat.isDirectory()) {
|
|
13
|
+
const children = fs.readdirSync(path);
|
|
14
|
+
if (0 === children.length) {
|
|
15
|
+
fs.rmdirSync(path);
|
|
16
|
+
} else {
|
|
17
|
+
children.forEach(item => {
|
|
18
|
+
const hitted = path + __V.FILE_DELIMITER + item;
|
|
19
|
+
__ioDeleteDir(hitted);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
__LOG.info(`删除文件:${path}`);
|
|
24
|
+
fs.unlinkSync(path);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const ioCopy = (from, to) => {
|
|
30
|
+
__FX.fxContinue(__IS.isExist(from) && !__IS.isExist(to) && __IS.isFile(from), () => {
|
|
31
|
+
const content = __IO.ioString(from);
|
|
32
|
+
__OUT.outString(to, content);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const ioDelete = (path) => {
|
|
37
|
+
__FX.fxError(__V.FILE_DELIMITER === path.trim(), 10024, path);
|
|
38
|
+
__ioDeleteDir(path);
|
|
39
|
+
};
|
|
40
|
+
module.exports = {
|
|
41
|
+
ioCopy,
|
|
42
|
+
ioDelete,
|
|
43
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const U = require("underscore");
|
|
3
|
+
|
|
4
|
+
const __CX = require('./ai.under.fn.cx.evaluate');
|
|
5
|
+
const __FX = require('./ai.under.fn.fx.terminal');
|
|
6
|
+
const __IO = require('./ai.path.fn.io.typed');
|
|
7
|
+
const __V = require('./zero.__.v.constant');
|
|
8
|
+
const __U = require('./zero.__.fn.find.util');
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const ioName = (path = '.') => {
|
|
11
|
+
const stat = fs.statSync(path);
|
|
12
|
+
if (stat.isDirectory()) {
|
|
13
|
+
return path.substring(path.lastIndexOf(__V.FILE_DELIMITER) + 1);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ioRoot = () => {
|
|
18
|
+
const folderInfo = __U.findTrace(__dirname);
|
|
19
|
+
let root = folderInfo.filter(item => item.endsWith("src"));
|
|
20
|
+
__FX.fxError(1 !== root.length, 10022, __dirname);
|
|
21
|
+
return root[0];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const ioDataA = (path) => {
|
|
26
|
+
// 先读取数据信息
|
|
27
|
+
__CX.cxExist(path);
|
|
28
|
+
const content = __IO.ioString(path);
|
|
29
|
+
try {
|
|
30
|
+
const parsed = JSON.parse(content);
|
|
31
|
+
if (U.isArray(parsed)) {
|
|
32
|
+
return parsed;
|
|
33
|
+
} else {
|
|
34
|
+
if (parsed.data && U.isArray(parsed.data)) {
|
|
35
|
+
return parsed.data;
|
|
36
|
+
} else {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const ioSwitch = (pathDir = ".") => {
|
|
45
|
+
// 截取当前运行目录
|
|
46
|
+
let pathStart;
|
|
47
|
+
if (pathDir.startsWith("/")) {
|
|
48
|
+
pathStart = pathDir;
|
|
49
|
+
} else {
|
|
50
|
+
pathStart = path.resolve(process.cwd(), pathDir);
|
|
51
|
+
}
|
|
52
|
+
return pathStart;
|
|
53
|
+
}
|
|
54
|
+
module.exports = {
|
|
55
|
+
ioName,
|
|
56
|
+
ioRoot,
|
|
57
|
+
ioDataA,
|
|
58
|
+
ioSwitch,
|
|
59
|
+
}
|