Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-pack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-pack
Commits
3422ea62
Commit
3422ea62
authored
Nov 13, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
ad946193
Pipeline
#175348
failed with stages
in 0 seconds
Changes
10
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
193 additions
and
398 deletions
+193
-398
index.es.js
dist/index.es.js
+36
-8
index.es.js.map
dist/index.es.js.map
+1
-1
index.js
dist/index.js
+36
-8
index.js.map
dist/index.js.map
+1
-1
index.umd.js
dist/index.umd.js
+36
-8
index.umd.js.map
dist/index.umd.js.map
+1
-1
index.js
src/index.js
+36
-8
project.js
tests/project.js
+34
-2
test.js
tests/test.js
+11
-3
test.json
tests/test.json
+1
-358
No files found.
dist/index.es.js
View file @
3422ea62
...
@@ -4,13 +4,32 @@
...
@@ -4,13 +4,32 @@
* 项目发布
* 项目发布
*/
*/
const
fs
=
require
(
'fs'
)
;
const
replaceFields
=
[
'page_title'
,
'container_id'
]
;
async
function
pack
(
project
,
getProcesses
,
getScripts
)
{
async
function
pack
(
project
,
options
)
{
let
version
=
Date
.
now
();
let
data
=
JSON
.
parse
(
project
.
data
);
let
data
=
JSON
.
parse
(
project
.
data
);
const
newTpl
=
await
pageTemplate
(
data
);
const
newData
=
await
packData
(
data
,
options
);
return
{
version
,
data
:
newData
,
tpl
:
newTpl
,
}
}
async
function
packData
(
data
,
{
getProcesses
,
getScripts
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
delete
newData
.
options
.
tpl
;
newData
.
views
=
data
.
views
;
newData
.
assets
=
data
.
assets
;
newData
.
dataMapping
=
data
.
dataMapping
;
newData
.
processes
=
data
.
processes
;
let
scriptIDs
=
[];
let
scriptIDs
=
[];
for
(
let
view
of
data
.
views
)
{
for
(
let
view
of
newData
.
views
)
{
traverseNode
(
view
,
(
node
)
=>
{
traverseNode
(
view
,
(
node
)
=>
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
...
@@ -22,7 +41,7 @@ async function pack(project, getProcesses, getScripts) {
...
@@ -22,7 +41,7 @@ async function pack(project, getProcesses, getScripts) {
});
});
}
}
//console.log('scriptIDs:', scriptIDs);
//console.log('scriptIDs:', scriptIDs);
let
scriptsContainer
=
d
ata
.
scripts
=
{};
let
scriptsContainer
=
newD
ata
.
scripts
=
{};
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
);
...
@@ -31,7 +50,7 @@ async function pack(project, getProcesses, getScripts) {
...
@@ -31,7 +50,7 @@ async function pack(project, getProcesses, getScripts) {
//console.log('scripts:', scriptsContainer);
//console.log('scripts:', scriptsContainer);
let
processIDs
=
[];
let
processIDs
=
[];
for
(
let
process
of
d
ata
.
processes
)
{
for
(
let
process
of
newD
ata
.
processes
)
{
for
(
let
key
in
process
.
sub
)
{
for
(
let
key
in
process
.
sub
)
{
let
p
=
process
.
sub
[
key
];
let
p
=
process
.
sub
[
key
];
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
...
@@ -40,15 +59,24 @@ async function pack(project, getProcesses, getScripts) {
...
@@ -40,15 +59,24 @@ async function pack(project, getProcesses, getScripts) {
}
}
}
}
//console.log('processIDs:', processIDs);
//console.log('processIDs:', processIDs);
let
builtinProcesses
=
d
ata
.
builtinProcesses
=
[];
let
builtinProcesses
=
newD
ata
.
builtinProcesses
=
[];
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);
fs
.
writeFileSync
(
'test.json'
,
JSON
.
stringify
(
data
));
return
JSON
.
stringify
(
newData
);
}
async
function
pageTemplate
(
data
,
options
)
{
const
{
tpl
,}
=
data
.
options
;
let
newTpl
=
tpl
;
for
(
let
field
of
replaceFields
)
{
newTpl
=
newTpl
.
replace
(
`$
${
field
.
toUpperCase
()}
$`
,
data
.
options
[
field
]);
}
return
newTpl
;
}
}
function
traverseNode
(
root
,
callback
)
{
function
traverseNode
(
root
,
callback
)
{
...
...
dist/index.es.js.map
View file @
3422ea62
{
"version"
:
3
,
"file"
:
"index.es.js"
,
"sources"
:
[
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目发布
\n
*/
\n\n
const fs = require('fs');
\n\n
export async function pack(project, getProcesses, getScripts) {\n
\t
let data = JSON.parse(project.data);
\n\n\t
let scriptIDs = [];
\n\t
for(let view of data.views){\n
\t\t
traverseNode(view, (node) => {\n
\t\t\t
if (node.scripts && node.scripts.length > 0) {\n
\t\t\t\t
for (let
{
script
}
of node.scripts) {\n
\t\t\t\t\t
if (!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\t
let scriptsContainer = data.scripts = {};
\n\t
const scripts = await getScripts(scriptIDs);
\n\t
for (let scriptData of scripts) {\n
\t\t
let {id, code} = JSON.parse(scriptData);
\n\t\t
scriptsContainer[id] = code;
\n\t
}
\n\t
//console.log('scripts:', scriptsContainer);
\n\n\t
let processIDs = [];
\n\t
for (let process of data.processes) {\n
\t\t
for (let key in process.sub) {\n
\t\t\t
let p = process.sub[key];
\n\t\t\t
if (!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\t
let builtinProcesses = data.builtinProcesses = [];
\n\t
let processes = await getProcesses(processIDs);
\n\t
for(let processData of processes){\n
\t\t
let process = JSON.parse(processData);
\n\t\t
builtinProcesses.push(process);
\n\t
}
\n\t
//console.log('processes:', data.processes);
\n\n\t
fs.writeFileSync('test.json', JSON.stringify(data));
\n
}
\n\n
function traverseNode(root, callback) {\n
\t
callback(root);
\n\t
if (root.children && root.children.length > 0) {\n
\t\t
for (let childNode of root.children) {\n
\t\t\t
traverseNode(childNode, callback);
\n\t\t
}
\n\t
}
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
"AAAA;;;;;;AAMA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,AAAO,eAAe,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE;CAC7D,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;CAEpC,IAAI,SAAS,GAAG,EAAE,CAAC;CACnB,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC;EAC1B,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK;GAC5B,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAA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EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;CACpD;;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\n
const replaceFields = ['page_title', 'container_id'];
\n\n
export async function pack(project, options) {\n
\t
let version = Date.now();
\n\t
let data = JSON.parse(project.data);
\n\t
const newTpl = await pageTemplate(data, options);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t\t
tpl: newTpl,
\n\t
}
\n
}
\n\n
async function packData(data, {getProcesses, getScripts}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
delete newData.options.tpl;
\n\t
newData.views = data.views;
\n\t
newData.assets = data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\n\t
let scriptIDs = [];
\n\t
for (let view of newData.views) {\n
\t\t
traverseNode(view, (node) => {\n
\t\t\t
if (node.scripts && node.scripts.length > 0) {\n
\t\t\t\t
for (let
{
script
}
of node.scripts) {\n
\t\t\t\t\t
if (!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\t
let scriptsContainer = newData.scripts = {};
\n\t
const scripts = await getScripts(scriptIDs);
\n\t
for (let scriptData of scripts) {\n
\t\t
let {id, code} = JSON.parse(scriptData);
\n\t\t
scriptsContainer[id] = code;
\n\t
}
\n\t
//console.log('scripts:', scriptsContainer);
\n\n\t
let processIDs = [];
\n\t
for (let process of newData.processes) {\n
\t\t
for (let key in process.sub) {\n
\t\t\t
let p = process.sub[key];
\n\t\t\t
if (!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\t
let builtinProcesses = newData.builtinProcesses = [];
\n\t
let processes = await getProcesses(processIDs);
\n\t
for (let processData of processes) {\n
\t\t
let process = JSON.parse(processData);
\n\t\t
builtinProcesses.push(process);
\n\t
}
\n\t
//console.log('processes:', data.processes);
\n\n\t
return JSON.stringify(newData);
\n
}
\n\n
async function pageTemplate(data, options) {\n
\t
const
{
tpl,
}
= data.options;
\n\t
let newTpl = tpl;
\n\t
for (let field of replaceFields) {\n
\t\t
newTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);
\n\t
}
\n\t
return newTpl;
\n
}
\n\n
function traverseNode(root, callback) {\n
\t
callback(root);
\n\t
if (root.children && root.children.length > 0) {\n
\t\t
for (let childNode of root.children) {\n
\t\t\t
traverseNode(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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AAQ,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
dist/index.js
View file @
3422ea62
...
@@ -8,13 +8,32 @@ Object.defineProperty(exports, '__esModule', { value: true });
...
@@ -8,13 +8,32 @@ Object.defineProperty(exports, '__esModule', { value: true });
* 项目发布
* 项目发布
*/
*/
const
fs
=
require
(
'fs'
)
;
const
replaceFields
=
[
'page_title'
,
'container_id'
]
;
async
function
pack
(
project
,
getProcesses
,
getScripts
)
{
async
function
pack
(
project
,
options
)
{
let
version
=
Date
.
now
();
let
data
=
JSON
.
parse
(
project
.
data
);
let
data
=
JSON
.
parse
(
project
.
data
);
const
newTpl
=
await
pageTemplate
(
data
);
const
newData
=
await
packData
(
data
,
options
);
return
{
version
,
data
:
newData
,
tpl
:
newTpl
,
}
}
async
function
packData
(
data
,
{
getProcesses
,
getScripts
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
delete
newData
.
options
.
tpl
;
newData
.
views
=
data
.
views
;
newData
.
assets
=
data
.
assets
;
newData
.
dataMapping
=
data
.
dataMapping
;
newData
.
processes
=
data
.
processes
;
let
scriptIDs
=
[];
let
scriptIDs
=
[];
for
(
let
view
of
data
.
views
)
{
for
(
let
view
of
newData
.
views
)
{
traverseNode
(
view
,
(
node
)
=>
{
traverseNode
(
view
,
(
node
)
=>
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
...
@@ -26,7 +45,7 @@ async function pack(project, getProcesses, getScripts) {
...
@@ -26,7 +45,7 @@ async function pack(project, getProcesses, getScripts) {
});
});
}
}
//console.log('scriptIDs:', scriptIDs);
//console.log('scriptIDs:', scriptIDs);
let
scriptsContainer
=
d
ata
.
scripts
=
{};
let
scriptsContainer
=
newD
ata
.
scripts
=
{};
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
);
...
@@ -35,7 +54,7 @@ async function pack(project, getProcesses, getScripts) {
...
@@ -35,7 +54,7 @@ async function pack(project, getProcesses, getScripts) {
//console.log('scripts:', scriptsContainer);
//console.log('scripts:', scriptsContainer);
let
processIDs
=
[];
let
processIDs
=
[];
for
(
let
process
of
d
ata
.
processes
)
{
for
(
let
process
of
newD
ata
.
processes
)
{
for
(
let
key
in
process
.
sub
)
{
for
(
let
key
in
process
.
sub
)
{
let
p
=
process
.
sub
[
key
];
let
p
=
process
.
sub
[
key
];
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
...
@@ -44,15 +63,24 @@ async function pack(project, getProcesses, getScripts) {
...
@@ -44,15 +63,24 @@ async function pack(project, getProcesses, getScripts) {
}
}
}
}
//console.log('processIDs:', processIDs);
//console.log('processIDs:', processIDs);
let
builtinProcesses
=
d
ata
.
builtinProcesses
=
[];
let
builtinProcesses
=
newD
ata
.
builtinProcesses
=
[];
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);
fs
.
writeFileSync
(
'test.json'
,
JSON
.
stringify
(
data
));
return
JSON
.
stringify
(
newData
);
}
async
function
pageTemplate
(
data
,
options
)
{
const
{
tpl
,}
=
data
.
options
;
let
newTpl
=
tpl
;
for
(
let
field
of
replaceFields
)
{
newTpl
=
newTpl
.
replace
(
`$
${
field
.
toUpperCase
()}
$`
,
data
.
options
[
field
]);
}
return
newTpl
;
}
}
function
traverseNode
(
root
,
callback
)
{
function
traverseNode
(
root
,
callback
)
{
...
...
dist/index.js.map
View file @
3422ea62
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目发布
\n
*/
\n\n
const fs = require('fs');
\n\n
export async function pack(project, getProcesses, getScripts) {\n
\t
let data = JSON.parse(project.data);
\n\n\t
let scriptIDs = [];
\n\t
for(let view of data.views){\n
\t\t
traverseNode(view, (node) => {\n
\t\t\t
if (node.scripts && node.scripts.length > 0) {\n
\t\t\t\t
for (let
{
script
}
of node.scripts) {\n
\t\t\t\t\t
if (!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\t
let scriptsContainer = data.scripts = {};
\n\t
const scripts = await getScripts(scriptIDs);
\n\t
for (let scriptData of scripts) {\n
\t\t
let {id, code} = JSON.parse(scriptData);
\n\t\t
scriptsContainer[id] = code;
\n\t
}
\n\t
//console.log('scripts:', scriptsContainer);
\n\n\t
let processIDs = [];
\n\t
for (let process of data.processes) {\n
\t\t
for (let key in process.sub) {\n
\t\t\t
let p = process.sub[key];
\n\t\t\t
if (!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\t
let builtinProcesses = data.builtinProcesses = [];
\n\t
let processes = await getProcesses(processIDs);
\n\t
for(let processData of processes){\n
\t\t
let process = JSON.parse(processData);
\n\t\t
builtinProcesses.push(process);
\n\t
}
\n\t
//console.log('processes:', data.processes);
\n\n\t
fs.writeFileSync('test.json', JSON.stringify(data));
\n
}
\n\n
function traverseNode(root, callback) {\n
\t
callback(root);
\n\t
if (root.children && root.children.length > 0) {\n
\t\t
for (let childNode of root.children) {\n
\t\t\t
traverseNode(childNode, callback);
\n\t\t
}
\n\t
}
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
";;;;AAAA;;;;;;AAMA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,AAAO,eAAe,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE;CAC7D,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;CAEpC,IAAI,SAAS,GAAG,EAAE,CAAC;CACnB,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC;EAC1B,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK;GAC5B,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;IAC5C,KAAK,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;KAClC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;MAChC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;MACvB;KACD;IACD;GACD,CAAC,CAAC;EACH;;CAED,IAAI,gBAAgB,GAAG,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;CACzC,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC;CAC5C,KAAK,IAAI,UAAU,IAAI,OAAO,EAAE;EAC/B,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,C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11-13.
\n
*
\n
* 项目发布
\n
*/
\n\n
const replaceFields = ['page_title', 'container_id'];
\n\n
export async function pack(project, options) {\n
\t
let version = Date.now();
\n\t
let data = JSON.parse(project.data);
\n\t
const newTpl = await pageTemplate(data, options);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t\t
tpl: newTpl,
\n\t
}
\n
}
\n\n
async function packData(data, {getProcesses, getScripts}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
delete newData.options.tpl;
\n\t
newData.views = data.views;
\n\t
newData.assets = data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\n\t
let scriptIDs = [];
\n\t
for (let view of newData.views) {\n
\t\t
traverseNode(view, (node) => {\n
\t\t\t
if (node.scripts && node.scripts.length > 0) {\n
\t\t\t\t
for (let
{
script
}
of node.scripts) {\n
\t\t\t\t\t
if (!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\t
let scriptsContainer = newData.scripts = {};
\n\t
const scripts = await getScripts(scriptIDs);
\n\t
for (let scriptData of scripts) {\n
\t\t
let {id, code} = JSON.parse(scriptData);
\n\t\t
scriptsContainer[id] = code;
\n\t
}
\n\t
//console.log('scripts:', scriptsContainer);
\n\n\t
let processIDs = [];
\n\t
for (let process of newData.processes) {\n
\t\t
for (let key in process.sub) {\n
\t\t\t
let p = process.sub[key];
\n\t\t\t
if (!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\t
let builtinProcesses = newData.builtinProcesses = [];
\n\t
let processes = await getProcesses(processIDs);
\n\t
for (let processData of processes) {\n
\t\t
let process = JSON.parse(processData);
\n\t\t
builtinProcesses.push(process);
\n\t
}
\n\t
//console.log('processes:', data.processes);
\n\n\t
return JSON.stringify(newData);
\n
}
\n\n
async function pageTemplate(data, options) {\n
\t
const
{
tpl,
}
= data.options;
\n\t
let newTpl = tpl;
\n\t
for (let field of replaceFields) {\n
\t\t
newTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);
\n\t
}
\n\t
return newTpl;
\n
}
\n\n
function traverseNode(root, callback) {\n
\t
callback(root);
\n\t
if (root.children && root.children.length > 0) {\n
\t\t
for (let childNode of root.children) {\n
\t\t\t
traverseNode(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,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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;;;;"
}
\ No newline at end of file
\ No newline at end of file
dist/index.umd.js
View file @
3422ea62
...
@@ -10,13 +10,32 @@
...
@@ -10,13 +10,32 @@
* 项目发布
* 项目发布
*/
*/
const
fs
=
require
(
'fs'
)
;
const
replaceFields
=
[
'page_title'
,
'container_id'
]
;
async
function
pack
(
project
,
getProcesses
,
getScripts
)
{
async
function
pack
(
project
,
options
)
{
let
version
=
Date
.
now
();
let
data
=
JSON
.
parse
(
project
.
data
);
let
data
=
JSON
.
parse
(
project
.
data
);
const
newTpl
=
await
pageTemplate
(
data
);
const
newData
=
await
packData
(
data
,
options
);
return
{
version
,
data
:
newData
,
tpl
:
newTpl
,
}
}
async
function
packData
(
data
,
{
getProcesses
,
getScripts
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
delete
newData
.
options
.
tpl
;
newData
.
views
=
data
.
views
;
newData
.
assets
=
data
.
assets
;
newData
.
dataMapping
=
data
.
dataMapping
;
newData
.
processes
=
data
.
processes
;
let
scriptIDs
=
[];
let
scriptIDs
=
[];
for
(
let
view
of
data
.
views
)
{
for
(
let
view
of
newData
.
views
)
{
traverseNode
(
view
,
(
node
)
=>
{
traverseNode
(
view
,
(
node
)
=>
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
...
@@ -28,7 +47,7 @@
...
@@ -28,7 +47,7 @@
});
});
}
}
//console.log('scriptIDs:', scriptIDs);
//console.log('scriptIDs:', scriptIDs);
let
scriptsContainer
=
d
ata
.
scripts
=
{};
let
scriptsContainer
=
newD
ata
.
scripts
=
{};
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
);
...
@@ -37,7 +56,7 @@
...
@@ -37,7 +56,7 @@
//console.log('scripts:', scriptsContainer);
//console.log('scripts:', scriptsContainer);
let
processIDs
=
[];
let
processIDs
=
[];
for
(
let
process
of
d
ata
.
processes
)
{
for
(
let
process
of
newD
ata
.
processes
)
{
for
(
let
key
in
process
.
sub
)
{
for
(
let
key
in
process
.
sub
)
{
let
p
=
process
.
sub
[
key
];
let
p
=
process
.
sub
[
key
];
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
...
@@ -46,15 +65,24 @@
...
@@ -46,15 +65,24 @@
}
}
}
}
//console.log('processIDs:', processIDs);
//console.log('processIDs:', processIDs);
let
builtinProcesses
=
d
ata
.
builtinProcesses
=
[];
let
builtinProcesses
=
newD
ata
.
builtinProcesses
=
[];
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);
fs
.
writeFileSync
(
'test.json'
,
JSON
.
stringify
(
data
));
return
JSON
.
stringify
(
newData
);
}
async
function
pageTemplate
(
data
,
options
)
{
const
{
tpl
,}
=
data
.
options
;
let
newTpl
=
tpl
;
for
(
let
field
of
replaceFields
)
{
newTpl
=
newTpl
.
replace
(
`$
${
field
.
toUpperCase
()}
$`
,
data
.
options
[
field
]);
}
return
newTpl
;
}
}
function
traverseNode
(
root
,
callback
)
{
function
traverseNode
(
root
,
callback
)
{
...
...
dist/index.umd.js.map
View file @
3422ea62
{
"version"
:
3
,
"file"
:
"index.umd.js"
,
"sources"
:
[
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目发布
\n
*/
\n\n
const fs = require('fs');
\n\n
export async function pack(project, getProcesses, getScripts) {\n
\t
let data = JSON.parse(project.data);
\n\n\t
let scriptIDs = [];
\n\t
for(let view of data.views){\n
\t\t
traverseNode(view, (node) => {\n
\t\t\t
if (node.scripts && node.scripts.length > 0) {\n
\t\t\t\t
for (let
{
script
}
of node.scripts) {\n
\t\t\t\t\t
if (!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\t
let scriptsContainer = data.scripts = {};
\n\t
const scripts = await getScripts(scriptIDs);
\n\t
for (let scriptData of scripts) {\n
\t\t
let {id, code} = JSON.parse(scriptData);
\n\t\t
scriptsContainer[id] = code;
\n\t
}
\n\t
//console.log('scripts:', scriptsContainer);
\n\n\t
let processIDs = [];
\n\t
for (let process of data.processes) {\n
\t\t
for (let key in process.sub) {\n
\t\t\t
let p = process.sub[key];
\n\t\t\t
if (!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\t
let builtinProcesses = data.builtinProcesses = [];
\n\t
let processes = await getProcesses(processIDs);
\n\t
for(let processData of processes){\n
\t\t
let process = JSON.parse(processData);
\n\t\t
builtinProcesses.push(process);
\n\t
}
\n\t
//console.log('processes:', data.processes);
\n\n\t
fs.writeFileSync('test.json', JSON.stringify(data));
\n
}
\n\n
function traverseNode(root, callback) {\n
\t
callback(root);
\n\t
if (root.children && root.children.length > 0) {\n
\t\t
for (let childNode of root.children) {\n
\t\t\t
traverseNode(childNode, callback);
\n\t\t
}
\n\t
}
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
";;;;;;CAAA;CACA;CACA;CACA;CACA;;CAEA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,CAAO,eAAe,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE;CAC9D,CAAC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;CAErC,CAAC,IAAI,SAAS,GAAG,EAAE,CAAC;CACpB,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,C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IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;CACnD,CAAC,IAAI,SAAS,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;CAChD,CAAC,IAAI,IAAI,WAAW,IAAI,SAAS,CAAC;CAClC,EAAE,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;CACxC,EAAE,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;CACjC,EAAE;CACF;;CAEA,CAAC,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;CACrD,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\n
const replaceFields = ['page_title', 'container_id'];
\n\n
export async function pack(project, options) {\n
\t
let version = Date.now();
\n\t
let data = JSON.parse(project.data);
\n\t
const newTpl = await pageTemplate(data, options);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t\t
tpl: newTpl,
\n\t
}
\n
}
\n\n
async function packData(data, {getProcesses, getScripts}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
delete newData.options.tpl;
\n\t
newData.views = data.views;
\n\t
newData.assets = data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\n\t
let scriptIDs = [];
\n\t
for (let view of newData.views) {\n
\t\t
traverseNode(view, (node) => {\n
\t\t\t
if (node.scripts && node.scripts.length > 0) {\n
\t\t\t\t
for (let
{
script
}
of node.scripts) {\n
\t\t\t\t\t
if (!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\t
let scriptsContainer = newData.scripts = {};
\n\t
const scripts = await getScripts(scriptIDs);
\n\t
for (let scriptData of scripts) {\n
\t\t
let {id, code} = JSON.parse(scriptData);
\n\t\t
scriptsContainer[id] = code;
\n\t
}
\n\t
//console.log('scripts:', scriptsContainer);
\n\n\t
let processIDs = [];
\n\t
for (let process of newData.processes) {\n
\t\t
for (let key in process.sub) {\n
\t\t\t
let p = process.sub[key];
\n\t\t\t
if (!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\t
let builtinProcesses = newData.builtinProcesses = [];
\n\t
let processes = await getProcesses(processIDs);
\n\t
for (let processData of processes) {\n
\t\t
let process = JSON.parse(processData);
\n\t\t
builtinProcesses.push(process);
\n\t
}
\n\t
//console.log('processes:', data.processes);
\n\n\t
return JSON.stringify(newData);
\n
}
\n\n
async function pageTemplate(data, options) {\n
\t
const
{
tpl,
}
= data.options;
\n\t
let newTpl = tpl;
\n\t
for (let field of replaceFields) {\n
\t\t
newTpl = newTpl.replace(`$${field.toUpperCase()}$`, data.options[field]);
\n\t
}
\n\t
return newTpl;
\n
}
\n\n
function traverseNode(root, callback) {\n
\t
callback(root);
\n\t
if (root.children && root.children.length > 0) {\n
\t\t
for (let childNode of root.children) {\n
\t\t\t
traverseNode(childNode, callback);
\n\t\t
}
\n\t
}
\n
}
\n
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MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;CAChD,CAAC,KAAK,IAAI,WAAW,IAAI,SAAS,EAAE;CACpC,EAAE,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;CACxC,EAAE,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;CACjC,EAAE;CACF;;CAEA,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
src/index.js
View file @
3422ea62
...
@@ -4,13 +4,32 @@
...
@@ -4,13 +4,32 @@
* 项目发布
* 项目发布
*/
*/
const
fs
=
require
(
'fs'
)
;
const
replaceFields
=
[
'page_title'
,
'container_id'
]
;
export
async
function
pack
(
project
,
getProcesses
,
getScripts
)
{
export
async
function
pack
(
project
,
options
)
{
let
version
=
Date
.
now
();
let
data
=
JSON
.
parse
(
project
.
data
);
let
data
=
JSON
.
parse
(
project
.
data
);
const
newTpl
=
await
pageTemplate
(
data
,
options
);
const
newData
=
await
packData
(
data
,
options
);
return
{
version
,
data
:
newData
,
tpl
:
newTpl
,
}
}
async
function
packData
(
data
,
{
getProcesses
,
getScripts
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
delete
newData
.
options
.
tpl
;
newData
.
views
=
data
.
views
;
newData
.
assets
=
data
.
assets
;
newData
.
dataMapping
=
data
.
dataMapping
;
newData
.
processes
=
data
.
processes
;
let
scriptIDs
=
[];
let
scriptIDs
=
[];
for
(
let
view
of
data
.
views
)
{
for
(
let
view
of
newData
.
views
)
{
traverseNode
(
view
,
(
node
)
=>
{
traverseNode
(
view
,
(
node
)
=>
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
if
(
node
.
scripts
&&
node
.
scripts
.
length
>
0
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
for
(
let
{
script
}
of
node
.
scripts
)
{
...
@@ -22,7 +41,7 @@ export async function pack(project, getProcesses, getScripts) {
...
@@ -22,7 +41,7 @@ export async function pack(project, getProcesses, getScripts) {
});
});
}
}
//console.log('scriptIDs:', scriptIDs);
//console.log('scriptIDs:', scriptIDs);
let
scriptsContainer
=
d
ata
.
scripts
=
{};
let
scriptsContainer
=
newD
ata
.
scripts
=
{};
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
);
...
@@ -31,7 +50,7 @@ export async function pack(project, getProcesses, getScripts) {
...
@@ -31,7 +50,7 @@ export async function pack(project, getProcesses, getScripts) {
//console.log('scripts:', scriptsContainer);
//console.log('scripts:', scriptsContainer);
let
processIDs
=
[];
let
processIDs
=
[];
for
(
let
process
of
d
ata
.
processes
)
{
for
(
let
process
of
newD
ata
.
processes
)
{
for
(
let
key
in
process
.
sub
)
{
for
(
let
key
in
process
.
sub
)
{
let
p
=
process
.
sub
[
key
];
let
p
=
process
.
sub
[
key
];
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
if
(
!
processIDs
.
includes
(
p
.
meta
))
{
...
@@ -40,15 +59,24 @@ export async function pack(project, getProcesses, getScripts) {
...
@@ -40,15 +59,24 @@ export async function pack(project, getProcesses, getScripts) {
}
}
}
}
//console.log('processIDs:', processIDs);
//console.log('processIDs:', processIDs);
let
builtinProcesses
=
d
ata
.
builtinProcesses
=
[];
let
builtinProcesses
=
newD
ata
.
builtinProcesses
=
[];
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);
fs
.
writeFileSync
(
'test.json'
,
JSON
.
stringify
(
data
));
return
JSON
.
stringify
(
newData
);
}
async
function
pageTemplate
(
data
,
options
)
{
const
{
tpl
,}
=
data
.
options
;
let
newTpl
=
tpl
;
for
(
let
field
of
replaceFields
)
{
newTpl
=
newTpl
.
replace
(
`$
${
field
.
toUpperCase
()}
$`
,
data
.
options
[
field
]);
}
return
newTpl
;
}
}
function
traverseNode
(
root
,
callback
)
{
function
traverseNode
(
root
,
callback
)
{
...
...
tests/project.js
View file @
3422ea62
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*/
*/
const
data
=
{
const
data
=
{
launchO
ptions
:
{
o
ptions
:
{
entrySceneView
:
'view1'
,
entrySceneView
:
'view1'
,
containerID
:
'game-container'
,
containerID
:
'game-container'
,
designWidth
:
750
,
designWidth
:
750
,
...
@@ -11,6 +11,38 @@ const data = {
...
@@ -11,6 +11,38 @@ const data = {
frameRate
:
60
,
frameRate
:
60
,
scaleMode
:
'fixedWidth'
,
scaleMode
:
'fixedWidth'
,
rendererType
:
'webgl'
,
rendererType
:
'webgl'
,
tpl
:
` <meta charset="UTF-8">
<title>$PAGE_TITLE$</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: white;
}
</style>
</head>
<body>
<div id="$CONTAINER_ID$" style="line-height:0;font-size:0"></div>
<script src="http://10.10.94.134:4002/dist/index.js"></script>
<script>
engine.launch('http://10.10.94.134:4002/examples/mock/test.json');
</script>
`
},
},
"views"
:
[{
"views"
:
[{
"name"
:
"view1"
,
"name"
:
"view1"
,
...
@@ -240,7 +272,7 @@ const data = {
...
@@ -240,7 +272,7 @@ const data = {
alias
:
'test'
,
alias
:
'test'
,
meta
:
'test'
,
meta
:
'test'
,
props
:
{
props
:
{
text
:
'
$_linked_$
'
,
text
:
'
Hello
'
,
},
},
output
:
{
output
:
{
success
:
[],
success
:
[],
...
...
tests/test.js
View file @
3422ea62
...
@@ -4,11 +4,19 @@
...
@@ -4,11 +4,19 @@
const
projectData
=
require
(
'./project'
);
const
projectData
=
require
(
'./project'
);
const
{
pack
}
=
require
(
'../dist/index'
);
const
{
pack
}
=
require
(
'../dist/index'
);
const
fs
=
require
(
'fs'
);
let
project
=
projectData
();
let
project
=
projectData
();
pack
(
project
.
data
,
getProcesses
,
getScripts
);
(
async
function
()
{
const
result
=
await
pack
(
project
.
data
,
{
getProcesses
,
getScripts
});
function
getProcesses
(
ids
){
const
{
version
,
data
,
tpl
}
=
result
;
fs
.
writeFileSync
(
'test.json'
,
data
);
console
.
log
(
'version:'
,
version
);
console
.
log
(
'template:
\
n'
,
tpl
);
})();
function
getProcesses
(
ids
)
{
return
[
return
[
JSON
.
stringify
({
JSON
.
stringify
({
id
:
'entry'
,
id
:
'entry'
,
...
@@ -20,7 +28,7 @@ function getProcesses(ids){
...
@@ -20,7 +28,7 @@ function getProcesses(ids){
]
]
}
}
function
getScripts
(
ids
){
function
getScripts
(
ids
)
{
return
[
return
[
JSON
.
stringify
({
JSON
.
stringify
({
id
:
'wave'
,
id
:
'wave'
,
...
...
tests/test.json
View file @
3422ea62
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment