зеркало из https://github.com/mozilla/hubs.git
Deploy working
This commit is contained in:
Родитель
0c718786bf
Коммит
52d7c26bdf
|
@ -4670,6 +4670,20 @@
|
|||
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
|
||||
"dev": true
|
||||
},
|
||||
"ora": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ora/-/ora-3.4.0.tgz",
|
||||
"integrity": "sha512-eNwHudNbO1folBP3JsZ19v9azXWtQZjICdr3Q0TDPIaeBQ3mXLrh54wM+er0+hSp+dWKf+Z8KM58CYzEyIYxYg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.4.2",
|
||||
"cli-cursor": "^2.1.0",
|
||||
"cli-spinners": "^2.0.0",
|
||||
"log-symbols": "^2.2.0",
|
||||
"strip-ansi": "^5.2.0",
|
||||
"wcwidth": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz",
|
||||
|
@ -5950,9 +5964,9 @@
|
|||
}
|
||||
},
|
||||
"cli-spinners": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.1.0.tgz",
|
||||
"integrity": "sha512-8B00fJOEh1HPrx4fo5eW16XmE1PcL1tGpGrxy63CXGP9nHdPBN63X75hA1zhvQuhVztJWLqV58Roj2qlNM7cAA==",
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.2.0.tgz",
|
||||
"integrity": "sha512-tgU3fKwzYjiLEQgPMD9Jt+JjHVL9kW93FiIMX/l7rivvOD4/LL0Mf7gda3+4U2KJBloybwgj5KEoQgGRioMiKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"cli-truncate": {
|
||||
|
@ -10554,6 +10568,12 @@
|
|||
"is-path-inside": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-interactive": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz",
|
||||
"integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==",
|
||||
"dev": true
|
||||
},
|
||||
"is-npm": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz",
|
||||
|
@ -12535,15 +12555,16 @@
|
|||
}
|
||||
},
|
||||
"ora": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ora/-/ora-3.4.0.tgz",
|
||||
"integrity": "sha512-eNwHudNbO1folBP3JsZ19v9azXWtQZjICdr3Q0TDPIaeBQ3mXLrh54wM+er0+hSp+dWKf+Z8KM58CYzEyIYxYg==",
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ora/-/ora-4.0.2.tgz",
|
||||
"integrity": "sha512-YUOZbamht5mfLxPmk4M35CD/5DuOkAacxlEUbStVXpBAt4fyhBf+vZHI/HRkI++QUp3sNoeA2Gw4C+hi4eGSig==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.4.2",
|
||||
"cli-cursor": "^2.1.0",
|
||||
"cli-spinners": "^2.0.0",
|
||||
"log-symbols": "^2.2.0",
|
||||
"cli-cursor": "^3.1.0",
|
||||
"cli-spinners": "^2.2.0",
|
||||
"is-interactive": "^1.0.0",
|
||||
"log-symbols": "^3.0.0",
|
||||
"strip-ansi": "^5.2.0",
|
||||
"wcwidth": "^1.0.1"
|
||||
},
|
||||
|
@ -12565,6 +12586,49 @@
|
|||
"supports-color": "^5.3.0"
|
||||
}
|
||||
},
|
||||
"cli-cursor": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
|
||||
"integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"restore-cursor": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"log-symbols": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz",
|
||||
"integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.4.2"
|
||||
}
|
||||
},
|
||||
"mimic-fn": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
|
||||
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
|
||||
"dev": true
|
||||
},
|
||||
"onetime": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz",
|
||||
"integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mimic-fn": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"restore-cursor": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz",
|
||||
"integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"onetime": "^5.1.0",
|
||||
"signal-exit": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
||||
|
|
|
@ -136,6 +136,7 @@
|
|||
"ncp": "^2.0.0",
|
||||
"node-fetch": "^2.6.0",
|
||||
"node-sass": "^4.12.0",
|
||||
"ora": "^4.0.2",
|
||||
"phoenix-channels": "^1.0.0",
|
||||
"prettier": "^1.7.0",
|
||||
"raw-loader": "^0.5.1",
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { readFileSync, existsSync } from "fs";
|
||||
import { readFileSync, existsSync, unlinkSync } from "fs";
|
||||
import { exec } from "child_process";
|
||||
import rmdir from "rimraf";
|
||||
import ncp from "ncp";
|
||||
import tar from "tar";
|
||||
import request from "request";
|
||||
import ora from "ora";
|
||||
|
||||
if (!existsSync(".ret.credentials")) {
|
||||
console.log("Not logged in, so cannot deploy. To log in, run npm run login.");
|
||||
|
@ -10,7 +12,8 @@ if (!existsSync(".ret.credentials")) {
|
|||
}
|
||||
|
||||
const { host, token } = JSON.parse(readFileSync(".ret.credentials"));
|
||||
console.log(`Deploying to ${host}.`);
|
||||
const spinner = ora(`Deploying to ${host}.`).start();
|
||||
const step = ora({ indent: 2 }).start();
|
||||
|
||||
const getTs = (() => {
|
||||
const p = n => (n < 10 ? `0${n}` : n);
|
||||
|
@ -24,7 +27,8 @@ const getTs = (() => {
|
|||
|
||||
(async () => {
|
||||
const headers = {
|
||||
Authorization: `Bearer ${token}`
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
|
||||
const res = await fetch(`https://${host}/api/ita/configs/hubs`, { headers });
|
||||
|
@ -37,62 +41,70 @@ const getTs = (() => {
|
|||
buildEnv.BUILD_VERSION = `1.0.0.${getTs()}`;
|
||||
const env = Object.assign(process.env, buildEnv);
|
||||
|
||||
//for (const d in ["./dist", "./admin/dist"]) {
|
||||
// rmdir(d, err => {
|
||||
// if (err) {
|
||||
// console.error(err);
|
||||
// process.exit(1);
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
for (const d in ["./dist", "./admin/dist"]) {
|
||||
rmdir(d, err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Building Client.");
|
||||
step.text = "Building Client.";
|
||||
|
||||
//await new Promise((resolve, reject) => {
|
||||
// exec("npm ci", { }, err => {
|
||||
// if (err) reject(err);
|
||||
// resolve();
|
||||
// });
|
||||
//});
|
||||
await new Promise((resolve, reject) => {
|
||||
exec("npm ci", {}, err => {
|
||||
if (err) reject(err);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
//await new Promise((resolve, reject) => {
|
||||
// exec("npm run build", { env }, (err, stdout) => {
|
||||
// if (err) reject(err);
|
||||
// resolve();
|
||||
// });
|
||||
//});
|
||||
await new Promise((resolve, reject) => {
|
||||
exec("npm run build", { env }, err => {
|
||||
if (err) reject(err);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
console.log("Building Admin Console.");
|
||||
step.text = "Building Admin Console.";
|
||||
|
||||
//await new Promise((resolve, reject) => {
|
||||
// exec("npm ci", { cwd: "./admin" }, err => {
|
||||
// if (err) reject(err);
|
||||
// resolve();
|
||||
// });
|
||||
//});
|
||||
await new Promise((resolve, reject) => {
|
||||
exec("npm ci", { cwd: "./admin" }, err => {
|
||||
if (err) reject(err);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
//await new Promise((resolve, reject) => {
|
||||
// exec("npm run build", { cwd: "./admin", env }, err => {
|
||||
// if (err) reject(err);
|
||||
// resolve();
|
||||
// });
|
||||
//});
|
||||
await new Promise((resolve, reject) => {
|
||||
exec("npm run build", { cwd: "./admin", env }, err => {
|
||||
if (err) reject(err);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
//await new Promise(res => {
|
||||
// ncp("./admin/dist", "./dist", err => {
|
||||
// if (err) {
|
||||
// console.error(err);
|
||||
// process.exit(1);
|
||||
// }
|
||||
await new Promise(res => {
|
||||
ncp("./admin/dist", "./dist", err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// res();
|
||||
// });
|
||||
//});
|
||||
console.log("Packaging Build.");
|
||||
const buildFile = `hubs-build-${buildEnv.BUILD_VERSION}.tar.gz`;
|
||||
await tar.c({ gzip: true, C: "dist", file: buildFile }, ["."]);
|
||||
res();
|
||||
});
|
||||
});
|
||||
step.text = "Packaging Build.";
|
||||
const uploadRes = await fetch(`https://${host}/api/ita/deploy/hubs/upload_url`, { headers });
|
||||
const uploadInfo = await uploadRes.json();
|
||||
|
||||
const { url, version } = await uploadRes.json();
|
||||
await tar.c({ gzip: true, C: "dist", file: "_build.tar.gz" }, ["."]);
|
||||
step.text = `Uploading Build ${buildEnv.BUILD_VERSION}.`;
|
||||
const req = request({ url, method: "put", body: readFileSync("_build.tar.gz") }); // Tried and failed to get this to use a stream :P
|
||||
unlinkSync("_build.tar.gz");
|
||||
await new Promise(res => req.on("end", res));
|
||||
step.text = "Build uploaded, deploying.";
|
||||
await fetch(`https://${host}/api/ita/deploy/hubs`, { headers, method: "POST", body: { version } });
|
||||
step.text = "Deploy finished.";
|
||||
step.stop();
|
||||
spinner.text = `Deployed to ${host}`;
|
||||
spinner.succeed();
|
||||
process.exit(0);
|
||||
})();
|
||||
|
|
Загрузка…
Ссылка в новой задаче