Jelajahi Sumber

mod: deploy

Ben 11 bulan lalu
induk
melakukan
92a3fe19e8
3 mengubah file dengan 5 tambahan dan 5 penghapusan
  1. 2 2
      js/deploy.js
  2. 2 2
      js/main.swift
  3. 1 1
      js/package.json

+ 2 - 2
js/deploy.js

@@ -1,5 +1,6 @@
 const AWS = require('aws-sdk');
 const fs = require("fs");
+const uuid = require('uuid');
 
 // 配置 AWS 访问凭证和 S3 区域
 AWS.config.update({
@@ -12,7 +13,7 @@ const s3 = new AWS.S3();
 
 const bucketName = 'justlistenmusic4560.com';
 const filePath = 'bundle.js';
-const destinationPath = 'bundle2.js';
+const destinationPath = `${uuid.v4()}.js`;
 
 const fileContent = fs.readFileSync(filePath);
 
@@ -22,7 +23,6 @@ const params = {
     Body: fileContent,
 };
 
-
 s3.upload(params)
     .promise()
     .then(data => {

+ 2 - 2
js/main.swift

@@ -138,10 +138,10 @@ func testSearch(keyword: String, ctx: JSContext) -> Void {
 
 let ctx = createJSContext()
 
-let remote = "https://d3crpuooyqht8f.cloudfront.net/bundle"
+let remote = "https://d3crpuooyqht8f.cloudfront.net/3f395c2e-a1cc-4bb5-8741-482cc2f1fc1e.js"
 let local = "https://d3crpuooyqht8f.cloudfront.net/bundle2.js"
 
-if let url = URL(string: local) {
+if let url = URL(string: remote) {
     downloadJSFile(url: url) { result in
         switch result {
         case .success(let jsString):

+ 1 - 1
js/package.json

@@ -6,7 +6,7 @@
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "run": "open ./index.html",
-    "build": "webpack"
+    "deploy": "webpack && node ./deploy.js"
   },
   "author": "",
   "license": "ISC",