Skip to content

Commit

Permalink
add index json (#35)
Browse files Browse the repository at this point in the history
* add index json

* update build

* add missing files
  • Loading branch information
dragazo authored May 7, 2024
1 parent a06e5a4 commit 306accf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- run: npm i && node build.js
- uses: actions/upload-pages-artifact@v1
with:
path: build
path: "."
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
- uses: actions/deploy-pages@v2
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# misc files
node_modules
<<<<<<< HEAD
build
package-lock.json
.DS_Store
build/
=======
.DS_Store
.vscode
>>>>>>> master

# template-generated files
/index.html
/index.json
10 changes: 5 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const _ = require('lodash');
const fs = require('fs');
const path = require('path');
const EXTENSIONS_DIR = path.join(__dirname, 'extensions');
const OUT_DIR = path.join(__dirname, 'build');
const TEMPLATES_DIR = path.join(__dirname, 'templates');

const extensions = fs.readdirSync(EXTENSIONS_DIR).map(readExtension);
const templates = fs.readdirSync(TEMPLATES_DIR);

try { fs.mkdirSync(OUT_DIR); } catch {}

fs.writeFileSync(path.join(OUT_DIR, 'index.html'), renderTemplate('index.html', { extensions }));
fs.copyFileSync('index.js', path.join(OUT_DIR, 'index.js'));
for (const template of templates) {
fs.writeFileSync(template, renderTemplate(path.join(TEMPLATES_DIR, template), { extensions }));
}

// ------------------------------------------

Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions templates/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
<% for (let i = 0; i < extensions.length; ++i) { ext = extensions[i]; %>
{
"name": "<%= ext.name %>",
"url": "<%= ext.scriptUrl %>"
}<% if (i !== extensions.length - 1) { %>,<% } %>
<% } %>
]
52 changes: 0 additions & 52 deletions utils/build-index.js

This file was deleted.

19 changes: 0 additions & 19 deletions utils/templates/README.md

This file was deleted.

0 comments on commit 306accf

Please sign in to comment.