Commit 89ecdf06 authored by rockyl's avatar rockyl

发布

parent 3f468bba
...@@ -42,12 +42,14 @@ async function packData(data, {getProcesses, getScripts}) { ...@@ -42,12 +42,14 @@ async function packData(data, {getProcesses, getScripts}) {
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; let scriptsContainer = newData.scripts = {};
if(scriptIDs.length > 0){
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let {id, code} = JSON.parse(scriptData);
scriptsContainer[id] = code; scriptsContainer[id] = code;
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
}
let processIDs = []; let processIDs = [];
for (let process of newData.processes) { for (let process of newData.processes) {
...@@ -60,12 +62,14 @@ async function packData(data, {getProcesses, getScripts}) { ...@@ -60,12 +62,14 @@ async function packData(data, {getProcesses, getScripts}) {
} }
//console.log('processIDs:', processIDs); //console.log('processIDs:', processIDs);
let builtinProcesses = newData.builtinProcesses = []; let builtinProcesses = newData.builtinProcesses = [];
if(processIDs.length > 0){
let processes = await getProcesses(processIDs); let processes = await getProcesses(processIDs);
for (let processData of processes) { for (let processData of processes) {
let process = JSON.parse(processData); let process = JSON.parse(processData);
builtinProcesses.push(process); builtinProcesses.push(process);
} }
//console.log('processes:', data.processes); //console.log('processes:', data.processes);
}
return JSON.stringify(newData); return JSON.stringify(newData);
} }
......
{"version":3,"file":"index.es.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst replaceFields = ['page_title', 'container_id'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now();\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tconst scripts = await getScripts(scriptIDs);\n\tfor (let scriptData of scripts) {\n\t\tlet {id, code} = JSON.parse(scriptData);\n\t\tscriptsContainer[id] = code;\n\t}\n\t//console.log('scripts:', scriptsContainer);\n\n\tlet processIDs = [];\n\tfor (let process of newData.processes) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!processIDs.includes(p.meta)) {\n\t\t\t\tprocessIDs.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\tlet processes = await getProcesses(processIDs);\n\tfor (let processData of processes) {\n\t\tlet process = JSON.parse(processData);\n\t\tbuiltinProcesses.push(process);\n\t}\n\t//console.log('processes:', data.processes);\n\n\treturn JSON.stringify(newData);\n}\n\nasync function pageTemplate(data, options) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tfor (let field of replaceFields) {\n\t\tnewTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}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C1C,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;CAC5B,IAAI,MAAM,GAAG,GAAG,CAAC;CACjB,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACzE;CACD,OAAO,MAAM,CAAC;CACd;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACrC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;"} {"version":3,"file":"index.es.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst replaceFields = ['page_title', 'container_id'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now();\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tif(scriptIDs.length > 0){\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet {id, code} = JSON.parse(scriptData);\n\t\t\tscriptsContainer[id] = code;\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet processIDs = [];\n\tfor (let process of newData.processes) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!processIDs.includes(p.meta)) {\n\t\t\t\tprocessIDs.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\tif(processIDs.length > 0){\n\t\tlet processes = await getProcesses(processIDs);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tbuiltinProcesses.push(process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\n\treturn JSON.stringify(newData);\n}\n\nasync function pageTemplate(data, options) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tfor (let field of replaceFields) {\n\t\tnewTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAAA;;;;;;AAMA,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;;AAErD,AAAO,eAAe,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE;CAC5C,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;CACzB,IAAI,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,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACzE;CACD,OAAO,MAAM,CAAC;CACd;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACrC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -46,12 +46,14 @@ async function packData(data, {getProcesses, getScripts}) { ...@@ -46,12 +46,14 @@ async function packData(data, {getProcesses, getScripts}) {
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; let scriptsContainer = newData.scripts = {};
if(scriptIDs.length > 0){
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let {id, code} = JSON.parse(scriptData);
scriptsContainer[id] = code; scriptsContainer[id] = code;
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
}
let processIDs = []; let processIDs = [];
for (let process of newData.processes) { for (let process of newData.processes) {
...@@ -64,12 +66,14 @@ async function packData(data, {getProcesses, getScripts}) { ...@@ -64,12 +66,14 @@ async function packData(data, {getProcesses, getScripts}) {
} }
//console.log('processIDs:', processIDs); //console.log('processIDs:', processIDs);
let builtinProcesses = newData.builtinProcesses = []; let builtinProcesses = newData.builtinProcesses = [];
if(processIDs.length > 0){
let processes = await getProcesses(processIDs); let processes = await getProcesses(processIDs);
for (let processData of processes) { for (let processData of processes) {
let process = JSON.parse(processData); let process = JSON.parse(processData);
builtinProcesses.push(process); builtinProcesses.push(process);
} }
//console.log('processes:', data.processes); //console.log('processes:', data.processes);
}
return JSON.stringify(newData); return JSON.stringify(newData);
} }
......
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst replaceFields = ['page_title', 'container_id'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now();\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tconst scripts = await getScripts(scriptIDs);\n\tfor (let scriptData of scripts) {\n\t\tlet {id, code} = JSON.parse(scriptData);\n\t\tscriptsContainer[id] = code;\n\t}\n\t//console.log('scripts:', scriptsContainer);\n\n\tlet processIDs = [];\n\tfor (let process of newData.processes) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!processIDs.includes(p.meta)) {\n\t\t\t\tprocessIDs.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\tlet processes = await getProcesses(processIDs);\n\tfor (let processData of processes) {\n\t\tlet process = JSON.parse(processData);\n\t\tbuiltinProcesses.push(process);\n\t}\n\t//console.log('processes:', data.processes);\n\n\treturn JSON.stringify(newData);\n}\n\nasync function pageTemplate(data, options) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tfor (let field of replaceFields) {\n\t\tnewTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMA,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;;AAErD,AAAO,eAAe,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE;CAC5C,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;CACzB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,AAAS,CAAC,CAAC;CACjD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;CAE9C,OAAO;EACN,OAAO;EACP,IAAI,EAAE,OAAO;EACb,GAAG,EAAE,MAAM;EACX;CACD;;AAED,eAAe,QAAQ,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE;CACzD,IAAI,OAAO,GAAG,EAAE,CAAC;CACjB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;CAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;CAC3B,OAAO,CAAC,KAA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AAC,EAAE;IACjC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACxB;GACD;EACD;;CAED,IAAI,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC;CACrD,IAAI,SAAS,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;CAC/C,KAAK,IAAI,WAAW,IAAI,SAAS,EAAE;EAClC,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;EACtC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;EAC/B;;;CAGD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CAC/B;;AAED,eAAe,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE;CAC1C,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;CAC5B,IAAI,MAAM,GAAG,GAAG,CAAC;CACjB,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACzE;CACD,OAAO,MAAM,CAAC;CACd;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACrC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;"} {"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst replaceFields = ['page_title', 'container_id'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now();\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tif(scriptIDs.length > 0){\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet {id, code} = JSON.parse(scriptData);\n\t\t\tscriptsContainer[id] = code;\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet processIDs = [];\n\tfor (let process of newData.processes) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!processIDs.includes(p.meta)) {\n\t\t\t\tprocessIDs.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\tif(processIDs.length > 0){\n\t\tlet processes = await getProcesses(processIDs);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tbuiltinProcesses.push(process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\n\treturn JSON.stringify(newData);\n}\n\nasync function pageTemplate(data, options) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tfor (let field of replaceFields) {\n\t\tnewTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMA,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;;AAErD,AAAO,eAAe,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE;CAC5C,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;CACzB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,AAAS,CAAC,CAAC;CACjD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;CAE9C,OAAO;EACN,OAAO;EACP,IAAI,EAAE,OAAO;EACb,GAAG,EAAE,MAAM;EACX;CACD;;AAED,eAAe,QAAQ,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE;CACzD,IAAI,OAAO,GAAG,EAAE,CAAC;CACjB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;CAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;CAC3B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;CAC3B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;CAC7B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;CACvC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;;CAEnC,IAAI,SAA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UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;EACxB,IAAI,SAAS,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;EAC/C,KAAK,IAAI,WAAW,IAAI,SAAS,EAAE;GAClC,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;GACtC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;GAC/B;;EAED;;CAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CAC/B;;AAED,eAAe,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE;CAC1C,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;CAC5B,IAAI,MAAM,GAAG,GAAG,CAAC;CACjB,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACzE;CACD,OAAO,MAAM,CAAC;CACd;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACrC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -48,12 +48,14 @@ ...@@ -48,12 +48,14 @@
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; let scriptsContainer = newData.scripts = {};
if(scriptIDs.length > 0){
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let {id, code} = JSON.parse(scriptData);
scriptsContainer[id] = code; scriptsContainer[id] = code;
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
}
let processIDs = []; let processIDs = [];
for (let process of newData.processes) { for (let process of newData.processes) {
...@@ -66,12 +68,14 @@ ...@@ -66,12 +68,14 @@
} }
//console.log('processIDs:', processIDs); //console.log('processIDs:', processIDs);
let builtinProcesses = newData.builtinProcesses = []; let builtinProcesses = newData.builtinProcesses = [];
if(processIDs.length > 0){
let processes = await getProcesses(processIDs); let processes = await getProcesses(processIDs);
for (let processData of processes) { for (let processData of processes) {
let process = JSON.parse(processData); let process = JSON.parse(processData);
builtinProcesses.push(process); builtinProcesses.push(process);
} }
//console.log('processes:', data.processes); //console.log('processes:', data.processes);
}
return JSON.stringify(newData); return JSON.stringify(newData);
} }
......
{"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst replaceFields = ['page_title', 'container_id'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now();\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tconst scripts = await getScripts(scriptIDs);\n\tfor (let scriptData of scripts) {\n\t\tlet {id, code} = JSON.parse(scriptData);\n\t\tscriptsContainer[id] = code;\n\t}\n\t//console.log('scripts:', scriptsContainer);\n\n\tlet processIDs = [];\n\tfor (let process of newData.processes) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!processIDs.includes(p.meta)) {\n\t\t\t\tprocessIDs.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\tlet processes = await getProcesses(processIDs);\n\tfor (let processData of processes) {\n\t\tlet process = JSON.parse(processData);\n\t\tbuiltinProcesses.push(process);\n\t}\n\t//console.log('processes:', data.processes);\n\n\treturn JSON.stringify(newData);\n}\n\nasync function pageTemplate(data, options) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tfor (let field of replaceFields) {\n\t\tnewTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;CAAA;CACA;CACA;CACA;CACA;;CAEA,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;;AAErD,CAAO,eAAe,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE;CAC7C,CAAC,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;CAC1B,CAAC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC,MAAM,MAAM,GAAG,M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AC3C,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;CAC7B,CAAC,IAAI,MAAM,GAAG,GAAG,CAAC;CAClB,CAAC,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;CAClC,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;CAC3E,EAAE;CACF,CAAC,OAAO,MAAM,CAAC;CACf,CAAC;;CAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACtC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAChB,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;CAChD,EAAE,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;CACvC,GAAG,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;CACrC,GAAG;CACH,EAAE;CACF,CAAC;;;;;;;;;;;;"} {"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst replaceFields = ['page_title', 'container_id'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now();\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tif(scriptIDs.length > 0){\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet {id, code} = JSON.parse(scriptData);\n\t\t\tscriptsContainer[id] = code;\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet processIDs = [];\n\tfor (let process of newData.processes) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!processIDs.includes(p.meta)) {\n\t\t\t\tprocessIDs.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\tif(processIDs.length > 0){\n\t\tlet processes = await getProcesses(processIDs);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tbuiltinProcesses.push(process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\n\treturn JSON.stringify(newData);\n}\n\nasync function pageTemplate(data, options) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tfor (let field of replaceFields) {\n\t\tnewTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;CAAA;CACA;CACA;CACA;CACA;;CAEA,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;;AAEr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M,YAAY,CAAC,UAAU,CAAC,CAAC;CACjD,EAAE,KAAK,IAAI,WAAW,IAAI,SAAS,EAAE;CACrC,GAAG,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;CACzC,GAAG,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;CAClC,GAAG;CACH;CACA,EAAE;;CAEF,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CAChC,CAAC;;CAED,eAAe,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE;CAC3C,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;CAC7B,CAAC,IAAI,MAAM,GAAG,GAAG,CAAC;CAClB,CAAC,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;CAClC,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;CAC3E,EAAE;CACF,CAAC,OAAO,MAAM,CAAC;CACf,CAAC;;CAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACtC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAChB,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;CAChD,EAAE,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;CACvC,GAAG,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;CACrC,GAAG;CACH,EAAE;CACF,CAAC;;;;;;;;;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -42,12 +42,14 @@ async function packData(data, {getProcesses, getScripts}) { ...@@ -42,12 +42,14 @@ async function packData(data, {getProcesses, getScripts}) {
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; let scriptsContainer = newData.scripts = {};
if(scriptIDs.length > 0){
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let {id, code} = JSON.parse(scriptData);
scriptsContainer[id] = code; scriptsContainer[id] = code;
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
}
let processIDs = []; let processIDs = [];
for (let process of newData.processes) { for (let process of newData.processes) {
...@@ -60,12 +62,14 @@ async function packData(data, {getProcesses, getScripts}) { ...@@ -60,12 +62,14 @@ async function packData(data, {getProcesses, getScripts}) {
} }
//console.log('processIDs:', processIDs); //console.log('processIDs:', processIDs);
let builtinProcesses = newData.builtinProcesses = []; let builtinProcesses = newData.builtinProcesses = [];
if(processIDs.length > 0){
let processes = await getProcesses(processIDs); let processes = await getProcesses(processIDs);
for (let processData of processes) { for (let processData of processes) {
let process = JSON.parse(processData); let process = JSON.parse(processData);
builtinProcesses.push(process); builtinProcesses.push(process);
} }
//console.log('processes:', data.processes); //console.log('processes:', data.processes);
}
return JSON.stringify(newData); return JSON.stringify(newData);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment