mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-21 08:51:54 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b96571b8ad | ||
|
|
bc86874ede | ||
|
|
4a9e7f6a6d | ||
|
|
2c52eeaa2b | ||
|
|
19246fac79 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
## [v0.0.4](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.3...v0.0.4) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- refactor: Dramatically simplify logging [`bc86874`](https://github.com/bcomnes/deploy-to-neocities/commit/bc86874ede188f9c33f0b6dfd2e54b25328b1285)
|
||||
|
||||
## [v0.0.3](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.2...v0.0.3) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- Fix boolean parsing [`19246fa`](https://github.com/bcomnes/deploy-to-neocities/commit/19246fac798151a3ab80666412f72394c0615c32)
|
||||
- bug: Fix reference bug in logging [`2c52eea`](https://github.com/bcomnes/deploy-to-neocities/commit/2c52eeaa2badbb1bcb3c2520e358fcc088bc3879)
|
||||
|
||||
## [v0.0.2](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.1...v0.0.2) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
@@ -4,10 +4,10 @@ branding:
|
||||
icon: cat
|
||||
color: yellow
|
||||
inputs:
|
||||
api-token: # api token for site to deploy to
|
||||
apiToken: # api token for site to deploy to
|
||||
description: 'Neocities API token for site to deploy to'
|
||||
required: true
|
||||
dist-dir:
|
||||
distDir:
|
||||
description: 'Local folder to deploy to neocities'
|
||||
default: 'public'
|
||||
required: true
|
||||
|
||||
99
index.js
99
index.js
@@ -3,101 +3,28 @@ const core = require('@actions/core')
|
||||
const Neocities = require('async-neocities')
|
||||
const path = require('path')
|
||||
const prettyTime = require('pretty-time')
|
||||
const prettyBytes = require('pretty-bytes')
|
||||
const assert = require('nanoassert')
|
||||
|
||||
async function doDeploy () {
|
||||
const token = core.getInput('api-token')
|
||||
const distDir = path.join(process.cwd(), core.getInput('dist-dir'))
|
||||
const cleanup = core.getInput('cleanup')
|
||||
const token = core.getInput('apiToken')
|
||||
const distDir = path.join(process.cwd(), core.getInput('distDir'))
|
||||
const cleanup = JSON.parse(core.getInput('cleanup'))
|
||||
assert(typeof cleanup === 'boolean', 'Cleanup input must be a boolean "true" or "false"')
|
||||
console.log(typeof cleanup)
|
||||
|
||||
const client = new Neocities(token)
|
||||
|
||||
const finalStats = await client.deploy(distDir, {
|
||||
const stats = await core.group('Deploying to neocities', client.deploy(distDir, {
|
||||
cleanup,
|
||||
statsCb: statsHandler({ cleanup, distDir })
|
||||
})
|
||||
statsCb: Neocities.statsHandler()
|
||||
}))
|
||||
|
||||
return finalStats
|
||||
console.log(`Deployed to Neocities in ${prettyTime([0, stats.time])}:`)
|
||||
console.log(` Uploaded ${stats.filesToUpload.length} files`)
|
||||
console.log(` ${cleanup ? 'Deleted' : 'Orphaned'} ${stats.filesToDelete.length} files`)
|
||||
console.log(` Skipped ${stats.filesSkipped.length} files`)
|
||||
}
|
||||
|
||||
doDeploy().then((finalStats) => {}).catch(err => {
|
||||
doDeploy().catch(err => {
|
||||
core.setFailed(err.message)
|
||||
})
|
||||
|
||||
function statsHandler (opts = {}) {
|
||||
return (stats) => {
|
||||
switch (stats.stage) {
|
||||
case 'inspecting': {
|
||||
switch (stats.status) {
|
||||
case 'start': {
|
||||
core.startGroup('Inspecting files')
|
||||
console.log('Inspecting local and remote files...')
|
||||
console.log(`Dist directory: ${opts.distDir})`)
|
||||
break
|
||||
}
|
||||
case 'progress': {
|
||||
break
|
||||
}
|
||||
case 'stop': {
|
||||
console.log(`Done inspecting local and remote files in ${prettyTime([0, stats.timer.elapsed])}`)
|
||||
const { tasks: { localScan, remoteScan } } = stats
|
||||
console.log(`Scanned ${localScan.numberOfFiles} local files (${prettyBytes(localScan.totalSize)}) in ${prettyTime([0, localScan.timer.elapsed])}`)
|
||||
console.log(`Scanned ${remoteScan.numberOfFiles} remote files (${prettyBytes(remoteScan.totalSize)}) in ${prettyTime([0, remoteScan.timer.elapsed])}`)
|
||||
core.endGroup()
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'diffing': {
|
||||
switch (stats.status) {
|
||||
case 'start': {
|
||||
core.startGroup('Diffing files')
|
||||
console.log('Diffing local and remote files...')
|
||||
break
|
||||
}
|
||||
case 'progress': {
|
||||
// No progress on diffing
|
||||
break
|
||||
}
|
||||
case 'stop': {
|
||||
const { tasks: { diffing } } = stats
|
||||
console.log(`Done diffing local and remote files in ${prettyTime([0, stats.timer.elapsed])}`)
|
||||
console.log(`${diffing.uploadCount} files to upload`)
|
||||
console.log(`${diffing.deleteCount} ` + (opts.cleanup ? 'files to delete' : 'orphaned files'))
|
||||
console.log(`${diffing.skipCoount} files to skip`)
|
||||
core.endGroup()
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'applying': {
|
||||
switch (stats.status) {
|
||||
case 'start': {
|
||||
core.startGroup('Applying diff')
|
||||
console.log('Uploading changes' + (opts.cleanup ? ' and deleting orphaned files...' : '...'))
|
||||
break
|
||||
}
|
||||
case 'progress': {
|
||||
break
|
||||
}
|
||||
case 'stop': {
|
||||
const { tasks: { uploadFiles, deleteFiles, skippedFiles } } = stats
|
||||
console.log('Done uploading changes' + (opts.cleanup ? ' and deleting orphaned files' : '') + ` in ${prettyTime([0, stats.timer.elapsed])}`)
|
||||
console.log(`Average upload speed: ${prettyBytes(uploadFiles.speed)}/s`)
|
||||
if (opts.cleanup) console.log(`Average delete speed: ${prettyBytes(deleteFiles.speed)}/s`)
|
||||
console.log(`Skipped ${skippedFiles.count} files (${prettyBytes(skippedFiles.size)})`)
|
||||
core.endGroup()
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
default: {
|
||||
console.log(stats)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "deploy-to-neocities",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.4",
|
||||
"description": "Github Action to deplpoy a folder to Neocities.org",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
|
||||
Reference in New Issue
Block a user