Spaces:
Build error
Build error
File size: 1,513 Bytes
d702d19 fbc42a6 a4be0a3 eccbbd1 fbc42a6 4207745 eccbbd1 fbc42a6 eccbbd1 a4be0a3 eccbbd1 fbc42a6 dd66be3 a4be0a3 fbc42a6 a4be0a3 eccbbd1 a4be0a3 fbc42a6 eccbbd1 fbc42a6 eccbbd1 fbc42a6 a4be0a3 eccbbd1 a4be0a3 eccbbd1 a4be0a3 eccbbd1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
console.log("ftp-start...")
const fs = require("fs");
const ftp = require("basic-ftp");
const path = require("path");
async function upload() {
const host = "ftpupload.net";
const user = "if0_39233887 ";
const password = "Zta26TKR6DGy";
if (!user || !password) {
console.error("環境変数 'FTPname' または 'FTPpsw' が設定されていません。");
return;
}
const client = new ftp.Client();
client.ftp.verbose = true;
client.ftp.timeout = 300000;
const localDist = path.join(__dirname, "dist");
if (!fs.existsSync(localDist)) {
console.error(`❌ 'dist' フォルダが存在しません: ${localDist}`);
return;
}
try {
console.log("FTPアップロードを開始します...");
console.log(`接続中: ${host}(ユーザー: ${user})`);
await client.access({
host,
user,
password,
secure: false,
});
console.log("接続に成功しました。");
const remoteDir = "s4s-editor.ct.ws/htdocs/";
await client.ensureDir(remoteDir);
await client.clearWorkingDir();
console.log(`ローカルの 'dist' ディレクトリをアップロード中: ${localDist}`);
await client.uploadFromDir(localDist);
console.log("✅ アップロードが完了しました!");
} catch (err) {
console.error("❌ アップロード中にエラーが発生しました:");
console.error(err);
} finally {
client.close();
console.log("FTP接続を閉じました。");
}
}
upload();
|