Comparing version 1.1.0 to 1.2.0
48
cli.js
#!/usr/bin/env node | ||
const rimraf = require("rimraf"); | ||
var FormData = require('form-data'); | ||
var fs = require('fs'); | ||
var program = require("commander"); | ||
var inquirer = require('inquirer'); | ||
var axios = require('axios'); | ||
var { zip } = require('zip-a-folder'); | ||
var package = require("./package.json"); | ||
const FormData = require('form-data'); | ||
const fs = require('fs'); | ||
const program = require("commander"); | ||
const inquirer = require('inquirer'); | ||
const got = require('got'); | ||
const { zip } = require('zip-a-folder'); | ||
const package = require("./package.json"); | ||
const concat = require("concat-stream") | ||
@@ -15,2 +15,5 @@ const cliProgress = require('cli-progress'); | ||
// const baseURL = "http://devospa.com" | ||
const baseURL = "http://localhost:3020" | ||
program | ||
@@ -29,9 +32,4 @@ .version(package.version, "-v, --version"); | ||
console.log(buildFolder + " folder will be zipped and uploaded to devospa.com") | ||
const api = axios.create({ | ||
maxContentLength: Infinity, | ||
maxBodyLength: Infinity, | ||
baseURL: "http://devospa.com", | ||
// baseURL: "http://localhost:3020", | ||
}) | ||
return api.post("/devospaApi/checkProjectToken", { token }).then(async() => { | ||
const url = baseURL+"/devospaApi/checkProjectToken" | ||
return got.post(url, { json: { token } }).then(async() => { | ||
return inquirer.prompt([ | ||
@@ -48,9 +46,2 @@ { | ||
await zip(buildFolder, zipPath); | ||
progressBar.update(10); | ||
let n = 10 | ||
const intervalObj = setInterval(() => { | ||
const nn = (100 + n) / 2 | ||
n += Math.min(10, nn - n) | ||
progressBar.update(n) | ||
}, 500) | ||
new Promise((resolve) => { | ||
@@ -63,11 +54,7 @@ const fd = new FormData(); | ||
}).then(({ data, headers }) => { | ||
return api.post("/devospaApi/upload", data, { | ||
headers, | ||
onUploadProgress: progressEvent => { | ||
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | ||
console.log(percentCompleted) | ||
progressBar.update(percentCompleted); | ||
} | ||
}).then((uploadResponse) => { | ||
clearInterval(intervalObj) | ||
return got.post(baseURL+"/devospaApi/upload", { body: data, headers}) | ||
.on('uploadProgress', progress => { | ||
progressBar.update(Math.round(progress.percent * 100)); | ||
}) | ||
.then((uploadResponse) => { | ||
progressBar.update(100) | ||
@@ -104,2 +91,3 @@ progressBar.stop(100) | ||
}).catch(e => { | ||
console.log(e) | ||
console.error("the project token is wrong, please copy the command from devospa.com") | ||
@@ -106,0 +94,0 @@ }) |
{ | ||
"name": "devospa", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"scripts": { | ||
"build": "node cli", | ||
"dev": "node cli.js", | ||
"publish": "node cli" | ||
"dev": "node cli.js" | ||
}, | ||
@@ -13,3 +11,2 @@ "bin": { | ||
"dependencies": { | ||
"axios": "^0.21.1", | ||
"cli-progress": "^3.9.0", | ||
@@ -19,2 +16,3 @@ "commander": "^7.2.0", | ||
"form-data": "^4.0.0", | ||
"got": "^11.8.2", | ||
"inquirer": "^8.1.1", | ||
@@ -21,0 +19,0 @@ "rimraf": "^3.0.2", |
4187
87
+ Addedgot@^11.8.2
+ Added@sindresorhus/is@4.6.0(transitive)
+ Added@szmarczak/http-timer@4.0.6(transitive)
+ Added@types/cacheable-request@6.0.3(transitive)
+ Added@types/http-cache-semantics@4.0.4(transitive)
+ Added@types/keyv@3.1.4(transitive)
+ Added@types/node@22.10.9(transitive)
+ Added@types/responselike@1.0.3(transitive)
+ Addedcacheable-lookup@5.0.4(transitive)
+ Addedcacheable-request@7.0.4(transitive)
+ Addedclone-response@1.0.3(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddefer-to-connect@2.0.1(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedgot@11.8.6(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedhttp2-wrapper@1.0.3(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlowercase-keys@2.0.0(transitive)
+ Addedmimic-response@1.0.13.1.0(transitive)
+ Addednormalize-url@6.1.0(transitive)
+ Addedp-cancelable@2.1.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedquick-lru@5.1.1(transitive)
+ Addedresolve-alpn@1.2.1(transitive)
+ Addedresponselike@2.0.1(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removedaxios@^0.21.1
- Removedaxios@0.21.4(transitive)
- Removedfollow-redirects@1.15.9(transitive)