-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
bbdf4a6
commit b6d509e
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Upload to KeyCDN | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
ftp-upload: | ||
name: 🎉 Upload | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🚚 Get latest code | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Update db.json and move it all to ./build/ | ||
run: | | ||
mkdir dist | ||
cp -R widgets/* dist/ | ||
npm install total4 | ||
node db.js | ||
cp db.json dist/db.json | ||
ls dist -la | ||
- name: FTP Deployer | ||
uses: sand4rt/[email protected] | ||
with: | ||
host: ${{ secrets.KEYCDN_SERVER }} | ||
username: ${{ secrets.KEYCDN_USERNAME }} | ||
password: ${{ secrets.KEYCDN_PASSWORD }} | ||
remote_folder: /cms/ | ||
local_folder: dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/db.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require('total4'); | ||
|
||
FUNC.indent = function(count, val) { | ||
|
||
var lines = val.split('\n'); | ||
var str = ''; | ||
var total = Math.abs(count); | ||
var is = false; | ||
|
||
for (var i = 0; i < total; i++) | ||
str += '\t'; | ||
|
||
for (var i = 0; i < lines.length; i++) { | ||
if (count > 0 && lines[i]) | ||
lines[i] = str + lines[i]; | ||
else if (lines[i].substring(0, total) === str) { | ||
lines[i] = lines[i].substring(total); | ||
is = true; | ||
} else if (lines[i] && !is) | ||
break; | ||
} | ||
|
||
return lines.join('\n'); | ||
}; | ||
|
||
PATH.fs.readdir('widgets', function(err, response) { | ||
|
||
var arr = []; | ||
var evaluate = function(code) { | ||
var obj = {}; | ||
new Function('exports', code)(obj); | ||
return obj; | ||
}; | ||
|
||
response.wait(function(filename, next) { | ||
|
||
PATH.fs.readFile('widgets/' + filename, function(err, response) { | ||
|
||
if (err) { | ||
next(); | ||
return; | ||
} | ||
|
||
var data = {}; | ||
data.id = filename.substring(0, filename.length - 5); | ||
|
||
response = response.toString('utf8'); | ||
|
||
var author = response.match(/exports\.author.*?;\n/); | ||
var name = response.match(/exports\.name.*?;\n/); | ||
var preview = response.match(/exports\.preview.*?;\n/); | ||
|
||
data.name = name ? evaluate(name[0]).name : ''; | ||
data.preview = preview ? evaluate(preview[0]).preview : ''; | ||
data.url = 'https://cdn.totaljs.com/cms/' + filename; | ||
data.author = author ? evaluate(author[0]).author : ''; | ||
arr.push(data); | ||
next(); | ||
}); | ||
|
||
}, function() { | ||
arr.quicksort('name'); | ||
PATH.fs.writeFile('db.json', JSON.stringify(arr, null, '\t'), NOOP); | ||
}); | ||
|
||
}); |