Compare commits

...

5 Commits

Author SHA1 Message Date
Bret Comnes
4a9e7f6a6d 0.0.3 2020-02-12 21:18:23 -07:00
Bret Comnes
2c52eeaa2b bug: Fix reference bug in logging 2020-02-12 21:17:13 -07:00
Bret Comnes
19246fac79 Fix boolean parsing 2020-02-12 21:14:59 -07:00
Bret Comnes
dda8316219 0.0.2 2020-02-12 21:01:52 -07:00
Bret Comnes
d9fb7899eb bug: Fix some logging bugs and add output 2020-02-12 21:00:58 -07:00
9 changed files with 59 additions and 37 deletions

View File

@@ -7,7 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
## 0.0.1 - 2020-02-12 ## [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
- bug: Fix some logging bugs and add output [`d9fb789`](https://github.com/bcomnes/deploy-to-neocities/commit/d9fb7899eb50b3386f9f99653b76999419f30a5d)
## v0.0.1 - 2020-02-12
### Commits ### Commits

View File

@@ -4,10 +4,10 @@ branding:
icon: cat icon: cat
color: yellow color: yellow
inputs: 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' description: 'Neocities API token for site to deploy to'
required: true required: true
dist-dir: distDir:
description: 'Local folder to deploy to neocities' description: 'Local folder to deploy to neocities'
default: 'public' default: 'public'
required: true required: true

View File

@@ -6,9 +6,10 @@ const prettyTime = require('pretty-time')
const prettyBytes = require('pretty-bytes') const prettyBytes = require('pretty-bytes')
async function doDeploy () { async function doDeploy () {
const token = core.getInput('api-token') const token = core.getInput('apiToken')
const distDir = path.join(process.cwd(), core.getInput('dist-dir')) const distDir = path.join(process.cwd(), core.getInput('distDir'))
const cleanup = core.getInput('cleanup') const cleanup = JSON.parse(core.getInput('cleanup'))
console.log(typeof cleanup)
const client = new Neocities(token) const client = new Neocities(token)
@@ -30,8 +31,9 @@ function statsHandler (opts = {}) {
case 'inspecting': { case 'inspecting': {
switch (stats.status) { switch (stats.status) {
case 'start': { case 'start': {
core.startGroup('Inspecting') core.startGroup('Inspecting files')
console.log(`Inspecting local (${opts.distDir}) and remote files...`) console.log('Inspecting local and remote files...')
console.log(`Dist directory: ${opts.distDir})`)
break break
} }
case 'progress': { case 'progress': {
@@ -63,8 +65,8 @@ function statsHandler (opts = {}) {
const { tasks: { diffing } } = stats const { tasks: { diffing } } = stats
console.log(`Done diffing local and remote files in ${prettyTime([0, stats.timer.elapsed])}`) console.log(`Done diffing local and remote files in ${prettyTime([0, stats.timer.elapsed])}`)
console.log(`${diffing.uploadCount} files to upload`) console.log(`${diffing.uploadCount} files to upload`)
console.log(`${diffing.deleteCount} ` + opts.cleanup ? 'files to delete' : 'orphaned files') console.log(`${diffing.deleteCount} ` + (opts.cleanup ? 'files to delete' : 'orphaned files'))
console.log(`${diffing.skipCoount} files to skip`) console.log(`${diffing.skipCount} files to skip`)
core.endGroup() core.endGroup()
break break
} }
@@ -75,7 +77,7 @@ function statsHandler (opts = {}) {
switch (stats.status) { switch (stats.status) {
case 'start': { case 'start': {
core.startGroup('Applying diff') core.startGroup('Applying diff')
console.log('Uploading changes' + opts.cleanup ? ' and deleting orphaned files...' : '...') console.log('Uploading changes' + (opts.cleanup ? ' and deleting orphaned files...' : '...'))
break break
} }
case 'progress': { case 'progress': {
@@ -83,7 +85,7 @@ function statsHandler (opts = {}) {
} }
case 'stop': { case 'stop': {
const { tasks: { uploadFiles, deleteFiles, skippedFiles } } = stats 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('Done uploading changes' + (opts.cleanup ? ' and deleting orphaned files' : '') + ` in ${prettyTime([0, stats.timer.elapsed])}`)
console.log(`Average upload speed: ${prettyBytes(uploadFiles.speed)}/s`) console.log(`Average upload speed: ${prettyBytes(uploadFiles.speed)}/s`)
if (opts.cleanup) console.log(`Average delete speed: ${prettyBytes(deleteFiles.speed)}/s`) if (opts.cleanup) console.log(`Average delete speed: ${prettyBytes(deleteFiles.speed)}/s`)
console.log(`Skipped ${skippedFiles.count} files (${prettyBytes(skippedFiles.size)})`) console.log(`Skipped ${skippedFiles.count} files (${prettyBytes(skippedFiles.size)})`)

View File

@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
## [v1.0.1](https://github.com/bcomnes/async-neocities/compare/v1.0.0...v1.0.1) - 2020-02-13
### Commits
- bug: Fix a number of logging bugs [`96fbea2`](https://github.com/bcomnes/async-neocities/commit/96fbea2bbd27ba1ac5105fce37e624d804dcbdb6)
## [v1.0.0](https://github.com/bcomnes/async-neocities/compare/v0.0.10...v1.0.0) - 2020-02-12 ## [v1.0.0](https://github.com/bcomnes/async-neocities/compare/v0.0.10...v1.0.0) - 2020-02-12
### Commits ### Commits

View File

@@ -277,7 +277,7 @@ class NeocitiesAPIClient {
for await (const file of iterator) { for await (const file of iterator) {
localFiles.push(file) localFiles.push(file)
localScan.numberOfFiles += 1 localScan.numberOfFiles += 1
localScan.totalSize += file.stat.blksize localScan.totalSize += file.stat.size
sendInspectionUpdate(PROGRESS) sendInspectionUpdate(PROGRESS)
} }
return localFiles return localFiles
@@ -291,7 +291,7 @@ class NeocitiesAPIClient {
// Inspection stage finalizer // Inspection stage finalizer
const [localFiles, remoteFiles] = await Promise.all([ const [localFiles, remoteFiles] = await Promise.all([
localScanJob, localScanJob,
this.list().then(res => res.files) remoteScanJob.then(res => res.files)
]) ])
inspectionStats.timer.stop() inspectionStats.timer.stop()
sendInspectionUpdate(STOP) sendInspectionUpdate(STOP)
@@ -315,6 +315,7 @@ class NeocitiesAPIClient {
const { tasks: { diffing } } = diffingStats const { tasks: { diffing } } = diffingStats
const { filesToUpload, filesToDelete, filesSkipped } = await neocitiesLocalDiff(remoteFiles, localFiles) const { filesToUpload, filesToDelete, filesSkipped } = await neocitiesLocalDiff(remoteFiles, localFiles)
diffingStats.timer.stop() diffingStats.timer.stop()
diffingStats.status = STOP diffingStats.status = STOP
diffing.uploadCount = filesToUpload.length diffing.uploadCount = filesToUpload.length
@@ -353,7 +354,7 @@ class NeocitiesAPIClient {
}, },
skippedFiles: { skippedFiles: {
count: filesSkipped.length, count: filesSkipped.length,
size: filesSkipped.reduce((accum, file) => accum + file.stat.blksize, 0) size: filesSkipped.reduce((accum, file) => accum + file.stat.size, 0)
} }
} }
} }

View File

View File

@@ -1,26 +1,26 @@
{ {
"_from": "async-neocities@1.0.0", "_from": "async-neocities@1.0.1",
"_id": "async-neocities@1.0.0", "_id": "async-neocities@1.0.1",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-iRdvlFfyyqS390fGzs/FJOFG5izOJFVG/0w/xRoqZ6ochmjkxiByp16zjBb1Ade5lvXuKTuBdM/sdqmIQvWe5w==", "_integrity": "sha512-5TVaKLYKnaHoSiluCP0i78e0CBZbeqBL6bgK8/QsM8YOAtrhd5JO9c5DEaW4SFpmf4wV0qcamQXh0A3C7CANLw==",
"_location": "/async-neocities", "_location": "/async-neocities",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "version",
"registry": true, "registry": true,
"raw": "async-neocities@1.0.0", "raw": "async-neocities@1.0.1",
"name": "async-neocities", "name": "async-neocities",
"escapedName": "async-neocities", "escapedName": "async-neocities",
"rawSpec": "1.0.0", "rawSpec": "1.0.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.0.0" "fetchSpec": "1.0.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": "https://registry.npmjs.org/async-neocities/-/async-neocities-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/async-neocities/-/async-neocities-1.0.1.tgz",
"_shasum": "cdb2d2c4f3a431ab2aba7982693f8922f94d4360", "_shasum": "3428ae48f48104b205a3537212090b00d9bbce45",
"_spec": "async-neocities@1.0.0", "_spec": "async-neocities@1.0.1",
"_where": "/Users/bret/repos/deploy-to-neocities", "_where": "/Users/bret/repos/deploy-to-neocities",
"author": { "author": {
"name": "Bret Comnes", "name": "Bret Comnes",
@@ -79,5 +79,5 @@
"dist" "dist"
] ]
}, },
"version": "1.0.0" "version": "1.0.1"
} }

20
node_modules/async-neocities/test.js generated vendored
View File

@@ -87,18 +87,18 @@ if (!fakeToken) {
tap.test('can deploy folders', async t => { tap.test('can deploy folders', async t => {
const client = new NeocitiesAPIClient(token) const client = new NeocitiesAPIClient(token)
// const statsCb = (stats) => { const statsCb = (stats) => {
// let logLine = `${stats.stage} ${stats.status} ${stats.timer.elapsed}` let logLine = `${stats.stage} ${stats.status} ${stats.timer.elapsed}`
// Object.entries(stats.tasks).forEach(([key, val]) => { Object.entries(stats.tasks).forEach(([key, val]) => {
// logLine += ` ${key}: ${JSON.stringify(val)}` logLine += ` ${key}: ${JSON.stringify(val)}`
// }) })
// console.log(logLine) console.log(logLine)
// } }
const deployStats = await client.deploy( const deployStats = await client.deploy(
resolve(__dirname, 'fixtures'), resolve(__dirname, 'fixtures'),
{ {
// statsCb, statsCb,
cleanup: false cleanup: false
} }
) )
@@ -110,7 +110,7 @@ if (!fakeToken) {
const redeployStats = await client.deploy( const redeployStats = await client.deploy(
resolve(__dirname, 'fixtures'), resolve(__dirname, 'fixtures'),
{ {
// statsCb, statsCb,
cleanup: false cleanup: false
} }
) )
@@ -122,7 +122,7 @@ if (!fakeToken) {
const cleanupStats = await client.deploy( const cleanupStats = await client.deploy(
resolve(__dirname, 'fixtures/empty'), resolve(__dirname, 'fixtures/empty'),
{ {
// statsCb, statsCb,
cleanup: true cleanup: true
} }
) )

View File

@@ -1,6 +1,6 @@
{ {
"name": "deploy-to-neocities", "name": "deploy-to-neocities",
"version": "0.0.1", "version": "0.0.3",
"description": "Github Action to deplpoy a folder to Neocities.org", "description": "Github Action to deplpoy a folder to Neocities.org",
"main": "index.js", "main": "index.js",
"private": true, "private": true,
@@ -39,7 +39,7 @@
"dependencies": { "dependencies": {
"@actions/core": "1.2.2", "@actions/core": "1.2.2",
"@actions/github": "2.1.0", "@actions/github": "2.1.0",
"async-neocities": "1.0.0", "async-neocities": "1.0.1",
"pretty-bytes": "^5.3.0", "pretty-bytes": "^5.3.0",
"pretty-time": "^1.1.0" "pretty-time": "^1.1.0"
}, },