Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hsmob

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hsmob - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

102

index.js

@@ -7,10 +7,17 @@ #!/usr/bin/env node

const chalk = require('chalk')
const argv = require('minimist')(process.argv.slice(2))
const commander = require('commander')
commander.option('-d, --dirName', 'package name').option('-n, --websiteName', 'website name')
const argv = require('minimist')(process.argv.slice(2))
commander
.option('-d, --dirName', 'package name')
.option('-n, --websiteName', 'website name')
.parse(process.argv)
;(async () => {
if (!argv.n) {
console.log(chalk.red.bold.bgWhite('请自定义子域名'))
return
}
let zipName
function readDir(zip, dirPath) {
const files = fs.readdirSync(dirPath)
files.forEach(fileName => {
files.forEach((fileName) => {
const fillPath = dirPath + '/' + fileName

@@ -41,5 +48,5 @@ const file = fs.statSync(fillPath)

compression: 'DEFLATE', // 压缩算法
compressionOptions: { level: 9 } // 压缩级别
compressionOptions: { level: 9 }, // 压缩级别
})
.then(async content => {
.then(async (content) => {
const dest = path.join(process.cwd(), './')

@@ -62,43 +69,58 @@ zipName = sourceDirName + '.zip'

process.exit()
browser.close()
}
try {
await generateZip()
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('http://show.hsmob.com/')
try {
await page.waitForSelector('input[type=file]', {
timeout: 2000
})
} catch (error) {
console.log(chalk.red.bold.bgWhite('网络有误,查看内网是否正常连接'))
end(zipName, browser)
}
console.log(chalk.green('上传中...'))
const inputUploadHandle = await page.$('input[type=file]')
await inputUploadHandle.uploadFile(zipName)
const checkbox = '#add-password'
await page.waitForSelector(checkbox)
await page.click(checkbox)
const input = '#password-input'
await page.waitForSelector(input)
await page.focus(input)
const websiteName = argv.n
await page.keyboard.type(websiteName)
const submit = '#upload-btn'
await page.waitForSelector(submit)
await page.click(submit)
await page.waitForTimeout(1000)
try {
const a = await page.waitForSelector(`input`, {
timeout: 15000
})
console.log(document.querySelector('input'))
} catch (error) {
console.log(chalk.red.bold.bgWhite('上传失败,文件中未包含 index.html ,自定义域名错误,文件格式错误,其他。'))
} catch (error) {
return
}
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
await page.goto('http://show.hsmob.com/')
try {
await page.waitForSelector('input[type=file]', {
timeout: 1000,
})
} catch (error) {
console.log(chalk.red.bold.bgWhite('网络有误,查看内网是否正常连接'))
end(zipName)
return
}
console.log(chalk.green('上传中...'))
const inputUploadHandle = await page.$('input[type=file]')
await inputUploadHandle.uploadFile(zipName)
const checkbox = '#add-password'
await page.waitForSelector(checkbox)
await page.click(checkbox)
const input = '#password-input'
await page.waitForSelector(input)
await page.focus(input)
const websiteName = argv.n
await page.keyboard.type(websiteName)
const submit = '#upload-btn'
await page.waitForSelector(submit)
await page.click(submit)
await page.waitForTimeout(1000)
page.waitForSelector('h1').then(async () => {
const element = await page.$eval('h1', (el) => el.textContent)
const isError = ['错误', 'wrong'].some((e) => element.includes(e))
if (isError) {
console.log(
chalk.red.bold.bgWhite(
'上传失败,文件中未包含 index.html ,自定义域名错误,文件格式错误,其他。'
)
)
end(zipName)
return
}
console.log(chalk.green(`上传成功:http://${websiteName}.show.hsmob.com`))
})
try {
const input = await page.waitForSelector('input', {
timeout: 15000,
})
const inputValue = await page.$eval('input', (el) => el.value)
console.log(33, inputValue)
console.log(chalk.green(`上传成功:${inputValue}`))
end(zipName)
browser.close()
} catch (error) {

@@ -105,0 +127,0 @@ end(zipName)

{
"name": "hsmob",
"version": "2.0.1",
"version": "2.0.2",
"description": "upload zip to show.hsmob.com",

@@ -18,3 +18,3 @@ "main": "index.js",

"author": "",
"license": "ISC"
}
"license": "MIT"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc