This commit is contained in:
parent
48c023d582
commit
9276e234ef
4 changed files with 39 additions and 0 deletions
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -17,6 +17,7 @@
|
|||
"jsdom": "^25.0.1",
|
||||
"luxon": "^3.3.0",
|
||||
"markdown-it-anchor": "^8.6.7",
|
||||
"neocities": "^0.0.3",
|
||||
"sharp": "^0.33.5"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -2333,6 +2334,15 @@
|
|||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||
},
|
||||
"node_modules/neocities": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/neocities/-/neocities-0.0.3.tgz",
|
||||
"integrity": "sha512-veH8WhrNz7l3YhSA2y6EHokCy45F19hUs14N3e1oVk5MWwg39bG7AeC9xp7WpdLqRkHQjy86J3aOy5Xvf3vslQ==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"form-data": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/node-retrieve-globals": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-retrieve-globals/-/node-retrieve-globals-6.0.0.tgz",
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
"jsdom": "^25.0.1",
|
||||
"luxon": "^3.3.0",
|
||||
"markdown-it-anchor": "^8.6.7",
|
||||
"neocities": "^0.0.3",
|
||||
"sharp": "^0.33.5"
|
||||
}
|
||||
}
|
||||
|
|
1
tools/neocities/test.html
Normal file
1
tools/neocities/test.html
Normal file
|
@ -0,0 +1 @@
|
|||
hello from node.js!
|
27
tools/publish-neocities.js
Normal file
27
tools/publish-neocities.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import dotenv from 'dotenv';
|
||||
import Neocities from 'neocities'
|
||||
|
||||
const uploadDir = 'tools/neocities';
|
||||
|
||||
async function listFiles() {
|
||||
const files = [];
|
||||
for (let name of await fs.readdir(uploadDir, { recursive: true })) {
|
||||
const file = path.join(uploadDir, name);
|
||||
const stat = await fs.stat(file);
|
||||
if (stat.isDirectory()) continue;
|
||||
files.push({ name: name, path: file });
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
dotenv.config();
|
||||
const api = new Neocities(process.env.NEOCITIES_USERNAME, process.env.NEOCITIES_PASSWORD);
|
||||
const files = await listFiles();
|
||||
const response = await new Promise(cb => api.upload(files, cb));
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
main();
|
Loading…
Reference in a new issue