File size: 884 Bytes
a4be0a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// upload.js
const ftp = require("basic-ftp");
const path = require("path");

async function upload() {
  // 環境変数からFTP情報を取得
  const host = "ftpupload.net";
  const user = process.env["FTP-name"];
  const password = process.env["FTP-psw"];

  if (!user || !password) {
    // 環境変数がなければ何もせず終了
    return;
  }

  const client = new ftp.Client();
  client.ftp.verbose = true;

  try {
    await client.access({
      host,
      user,
      password,
      secure: false,
    });

    // アップロード先ディレクトリ
    await client.ensureDir("s4s-editor.ct.ws/htdocs/");
    await client.clearWorkingDir();

    // ローカルのdistフォルダをアップロード
    await client.uploadFromDir(path.join(__dirname, "dist"));
  } catch (err) {
    console.error(err);
  } finally {
    client.close();
  }
}

upload();