Skip to content

Commit

Permalink
fixed helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Grove committed Jul 30, 2018
1 parent 8eae7ac commit f6adfa9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
25 changes: 5 additions & 20 deletions snow-helpers/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function check_config(success,error,prompt_num){
current: config.application.scope,
properties: {
answer: {
pattern: /^[a-zA-Z0-9-_]+$/,
pattern: /^[a-zA-Z0-9-]+$/,
description: colors.green('Enter an application scope'),
required: true
}
Expand Down Expand Up @@ -322,26 +322,12 @@ function create_files(){
active: "true",
use_scoped_format: "true",
global: "false",
script_name: "inline",
script_name: "runtime",
script: "",
sys_class_name: "sys_ui_script",
sys_package: config.application.sys_id,
name: config.application.scope + ".inline",
sys_name: config.application.scope + ".inline",
sys_scope: config.application.sys_id
}
},{
table: "sys_ui_script",
body: {
active: "true",
use_scoped_format: "true",
global: "false",
script_name: "vendor",
script: "",
sys_class_name: "sys_ui_script",
sys_package: config.application.sys_id,
name: config.application.scope + ".vendor",
sys_name: config.application.scope + ".vendor",
name: config.application.scope + ".runtime",
sys_name: config.application.scope + ".runtime",
sys_scope: config.application.sys_id
}
},{
Expand Down Expand Up @@ -403,9 +389,8 @@ function create_files(){

if (file.body.name == 'index') config.files.html['index'] = record.sys_id;
if (file.body.name == 'index') config.snow.endpoint = record.endpoint;
if (file.body.name == config.application.scope + '.inline') config.files.js['inline'] = record.sys_id;
if (file.body.name == config.application.scope + '.main') config.files.js['main'] = record.sys_id;
if (file.body.name == config.application.scope + '.vendor') config.files.js['vendor'] = record.sys_id;
if (file.body.name == config.application.scope + '.runtime') config.files.js['runtime'] = record.sys_id;
if (file.body.name == config.application.scope + '.polyfills') config.files.js['polyfills'] = record.sys_id;
if (file.body.name == 'styles') config.files.css['styles'] = record.sys_id;

Expand Down
24 changes: 14 additions & 10 deletions snow-helpers/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,16 @@ fs.readdir("./dist",function(err,files){
if (file.match(/^index.html$/g)){
upload_file(file,'sys_ui_page',config.files.html.index);

} else if (file.match(/^main\.[0-9a-z]+\.bundle\.js$/)){
} else if (file.match(/^main\.[0-9a-z]+\.js$/)){
upload_file(file,'sys_ui_script',config.files.js.main);

} else if (file.match(/^inline\.[0-9a-z]+\.bundle\.js$/g)){
upload_file(file,'sys_ui_script',config.files.js.inline);

} else if (file.match(/^polyfills\.[0-9a-z]+\.bundle\.js$/g)){
} else if (file.match(/^polyfills\.[0-9a-z]+\.js$/g)){
upload_file(file,'sys_ui_script',config.files.js.polyfills);

} else if (file.match(/^vendor\.[0-9a-z]+\.bundle\.js$/g)){
upload_file(file,'sys_ui_script',config.files.js.vendor);
} else if (file.match(/^runtime\.[0-9a-z]+\.js$/g)){
upload_file(file,'sys_ui_script',config.files.js.runtime);

} else if (file.match(/^styles\.[0-9a-z]+\.bundle\.css$/g)){
} else if (file.match(/^styles\.[0-9a-z]+\.css$/g)){
upload_file(file,'content_css',config.files.css.styles);
}
}
Expand Down Expand Up @@ -73,14 +70,21 @@ function upload_file(file,table,sys_id){
body[fields[table]] = fs.readFileSync('./dist/' + file).toString();

if (table == 'sys_ui_page') {

// strip some build stuff not needed for SNow
body[fields[table]] = body[fields[table]].replace('<base href="/">','');
body[fields[table]] = body[fields[table]].replace(/<link .*href="styles\.[0-9a-f]+\.css">/,'');
body[fields[table]] = body[fields[table]].replace(/<\/head>/g,'<link href="{{styles}}.cssdbx" rel="stylesheet" type="text/css" /></head>');
body[fields[table]] = body[fields[table]].replace(/(<link.*)\/>/g,"$1><\/link>");
body[fields[table]] = body[fields[table]].replace(/<script.*src.*<\/script>/g,'');

for (key in config.files.css){
var check = '{{' + key + '}}';
var regex = new RegExp(check,'g');
body[fields[table]] = body[fields[table]].toString().replace(regex,config.files.css[key]);
}

// strip some build garabage
body[fields[table]] = body[fields[table]].replace('<base href="/">','');

}

var req = http.request(options, function(res) {
Expand Down

0 comments on commit f6adfa9

Please sign in to comment.