mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-21 00:46:29 +00:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ac7b56408 | ||
|
|
3024afb807 | ||
|
|
60d959d7ed | ||
|
|
6d0a96de91 | ||
|
|
da5f527254 | ||
|
|
6bcb1bafa6 | ||
|
|
df9c0b9fe1 | ||
|
|
bcc9d90095 | ||
|
|
7092d0c55c | ||
|
|
6b86fa30b4 | ||
|
|
74e6c4a57e | ||
|
|
8b470dbfd8 | ||
|
|
0dd3a06ef7 | ||
|
|
bf2d333152 | ||
|
|
f13458cc2d | ||
|
|
5e6f9848c7 | ||
|
|
fad2c4a165 | ||
|
|
1638c39428 | ||
|
|
c50fdeb3e6 | ||
|
|
48d2e5e4e0 | ||
|
|
aaf8a90973 | ||
|
|
34601c4927 | ||
|
|
ce8f0e70b0 | ||
|
|
22ef26e851 | ||
|
|
b96571b8ad | ||
|
|
bc86874ede |
60
CHANGELOG.md
60
CHANGELOG.md
@@ -7,6 +7,66 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
## [v1.0.0](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.11...v1.0.0) - 2020-02-18
|
||||
|
||||
### Merged
|
||||
|
||||
- Update dependencies to enable Greenkeeper 🌴 [`#1`](https://github.com/bcomnes/deploy-to-neocities/pull/1)
|
||||
|
||||
### Commits
|
||||
|
||||
- docs: Document action, inputs and outputs. [`da5f527`](https://github.com/bcomnes/deploy-to-neocities/commit/da5f52725420f64188f5130c7bb54fda5252e3ec)
|
||||
- docs: add missing example [`3024afb`](https://github.com/bcomnes/deploy-to-neocities/commit/3024afb80791888e8c0fd04cf23ba6e7560a5f40)
|
||||
- Update README.md [`df9c0b9`](https://github.com/bcomnes/deploy-to-neocities/commit/df9c0b9fe144eb76092e3998b2013e130756c950)
|
||||
|
||||
## [v0.0.11](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.10...v0.0.11) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- bug: fix time formatting [`8b470db`](https://github.com/bcomnes/deploy-to-neocities/commit/8b470dbfd876d61b6bd72327952bd1d9b0b49c9b)
|
||||
|
||||
## [v0.0.10](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.9...v0.0.10) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- chore: deps [`bf2d333`](https://github.com/bcomnes/deploy-to-neocities/commit/bf2d333152be116ec87d35592c8cb9ee4ef6821b)
|
||||
|
||||
## [v0.0.9](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.8...v0.0.9) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- chore: update deps [`5e6f984`](https://github.com/bcomnes/deploy-to-neocities/commit/5e6f9848c78a5f3a668b47a27dc14835005bf98c)
|
||||
|
||||
## [v0.0.8](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.7...v0.0.8) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- chore: update async-neocities to 1.1.3 [`1638c39`](https://github.com/bcomnes/deploy-to-neocities/commit/1638c394287dcf61bcf439a387dbefc2e68b2128)
|
||||
|
||||
## [v0.0.7](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.6...v0.0.7) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- refactor: Remove core calls [`48d2e5e`](https://github.com/bcomnes/deploy-to-neocities/commit/48d2e5e4e064176c8c4d27eddea40d0009446dba)
|
||||
|
||||
## [v0.0.6](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.5...v0.0.6) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- bug: update async-neocities to 1.1.2 [`34601c4`](https://github.com/bcomnes/deploy-to-neocities/commit/34601c49277891d15395a79b28eeb21781a019da)
|
||||
|
||||
## [v0.0.5](https://github.com/bcomnes/deploy-to-neocities/compare/v0.0.4...v0.0.5) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- bug: Use correct version of async-neocities [`22ef26e`](https://github.com/bcomnes/deploy-to-neocities/commit/22ef26e851efa57357d731a73a1f606dc212608a)
|
||||
|
||||
## [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
|
||||
|
||||
67
README.md
67
README.md
@@ -2,8 +2,75 @@
|
||||
|
||||
[](https://github.com/bcomnes/deploy-to-neocities/actions)
|
||||
|
||||
<center><img src="logo.png"></center>
|
||||
|
||||
Efficiently deploy a website to [Neocities][nc].
|
||||
|
||||
### Pre-requisites
|
||||
Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
|
||||
|
||||
Get your sites API token and set a [secret][sec] called `NEOCITIES_API_TOKEN`. Set the `api_token` input on your `deploy-to-neocities` action to `NEOCITIES_API_TOKEN`.
|
||||
|
||||
```
|
||||
https://neocities.org/settings/{{sitename}}#api_key
|
||||
```
|
||||
|
||||
During your workflow, generate the files you want to deploy to [Neocities][nc] into a `distDir` directory. You can use any tools that can be installed or brought into the Github actions environment.
|
||||
|
||||
This `dist_dir` should be specified as the `distDir` input. Once the build is complete, the `deploy-to-neocities` action will efficiently upload all new and all changed files to Neocities. Any files on Neocities that don't exist in the `distDir` are considdered 'orphaned' files. To destrucively remove these 'orphaned' files, set the `cleanup` input to `true`.
|
||||
|
||||
You most likely only want to run this on the `master` branch so that only changes commited to `master` result in website updates.
|
||||
|
||||
### Example workflow
|
||||
|
||||
```yaml
|
||||
name: Deploy to neociteis
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
- name: Install deps and build
|
||||
run: |
|
||||
npm i
|
||||
npm run build
|
||||
- name: Deploy to neocities
|
||||
uses: bcomnes/deploy-to-neocities@v1
|
||||
with:
|
||||
api_token: ${{ secrets.NEOCITIES_API_TOKEN }}
|
||||
cleanup: false
|
||||
dist_dir: public
|
||||
```
|
||||
|
||||
### Inputs
|
||||
|
||||
- `api_token` (**REQUIRED**): The api token for your [Neocities][nc] website to deploy to.
|
||||
- `dist_dir`: The directory to deploy to [Neocities][nc]. Default: `public`.
|
||||
- `cleanup`: Boolean string (`true` or `false`). If `true`, `deploy-to-neocities` will destructively delete files found on [Neocoties][nc] not found in your `dist_dir`. Default: `false`.
|
||||
|
||||
### Outputs
|
||||
|
||||
None.
|
||||
|
||||
## See also
|
||||
|
||||
- [async-neocities](https://ghub.io/async-neocities): diffing engine used for action.
|
||||
- [Neocities API Docs](https://neocities.org/api)
|
||||
- [neocities/neocities-node](https://github.com/neocities/neocities-node): Node api
|
||||
|
||||
[qs]: https://ghub.io/qs
|
||||
[nf]: https://ghub.io/node-fetch
|
||||
[fd]: https://ghub.io/form-data
|
||||
[nc]: https://neocities.org
|
||||
[sec]: https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
name: 'Deploy to Neocities'
|
||||
description: 'Github Action to deplpoy a folder to Neocities.org'
|
||||
description: 'Efficiently deplpoy a folder to Neocities.org'
|
||||
branding:
|
||||
icon: cat
|
||||
color: yellow
|
||||
icon: aperture
|
||||
color: orange
|
||||
inputs:
|
||||
apiToken: # api token for site to deploy to
|
||||
api_token: # api token for site to deploy to
|
||||
description: 'Neocities API token for site to deploy to'
|
||||
required: true
|
||||
distDir:
|
||||
|
||||
99
index.js
99
index.js
@@ -2,102 +2,29 @@ const core = require('@actions/core')
|
||||
// const github = require('@actions/github')
|
||||
const Neocities = require('async-neocities')
|
||||
const path = require('path')
|
||||
const prettyTime = require('pretty-time')
|
||||
const prettyBytes = require('pretty-bytes')
|
||||
const ms = require('ms')
|
||||
const assert = require('nanoassert')
|
||||
|
||||
async function doDeploy () {
|
||||
const token = core.getInput('apiToken')
|
||||
const distDir = path.join(process.cwd(), core.getInput('distDir'))
|
||||
const token = core.getInput('api_token')
|
||||
const distDir = path.join(process.cwd(), core.getInput('dist_dir'))
|
||||
const cleanup = JSON.parse(core.getInput('cleanup'))
|
||||
console.log(typeof cleanup)
|
||||
assert(typeof cleanup === 'boolean', 'Cleanup input must be a boolean "true" or "false"')
|
||||
|
||||
const client = new Neocities(token)
|
||||
|
||||
const finalStats = await client.deploy(distDir, {
|
||||
const stats = await client.deploy(distDir, {
|
||||
cleanup,
|
||||
statsCb: statsHandler({ cleanup, distDir })
|
||||
statsCb: Neocities.statsHandler()
|
||||
})
|
||||
|
||||
return finalStats
|
||||
console.log(`Deployed to Neocities in ${ms(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 => {
|
||||
console.error(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.skipCount} 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
node_modules/async-neocities/CHANGELOG.md
generated
vendored
48
node_modules/async-neocities/CHANGELOG.md
generated
vendored
@@ -7,6 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
## [v1.1.6](https://github.com/bcomnes/async-neocities/compare/v1.1.5...v1.1.6) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- refactor: limit decimal places in statHandler [`745b5c0`](https://github.com/bcomnes/async-neocities/commit/745b5c08b446723b837cf787e5911045cd0a01ed)
|
||||
|
||||
## [v1.1.5](https://github.com/bcomnes/async-neocities/compare/v1.1.4...v1.1.5) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- bug: Log last stats before clear [`c4c83f8`](https://github.com/bcomnes/async-neocities/commit/c4c83f8e329303404dfec6a2943d8b01783040ad)
|
||||
|
||||
## [v1.1.4](https://github.com/bcomnes/async-neocities/compare/v1.1.3...v1.1.4) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- bug: fix logging handler logic [`f6c5921`](https://github.com/bcomnes/async-neocities/commit/f6c5921d6fd0a420c5895ed6ba2fe2f766e726fd)
|
||||
|
||||
## [v1.1.3](https://github.com/bcomnes/async-neocities/compare/v1.1.2...v1.1.3) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- refactor: Stop logging progress when the stream has been read. [`3ce0fc4`](https://github.com/bcomnes/async-neocities/commit/3ce0fc452acbbbd28c39b53a3a9a4318a8019c09)
|
||||
|
||||
## [v1.1.2](https://github.com/bcomnes/async-neocities/compare/v1.1.1...v1.1.2) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- bug: Fix export name of statsHandler [`8958e5e`](https://github.com/bcomnes/async-neocities/commit/8958e5eeb947376690a1ce0cefe7cce3d59be5b8)
|
||||
|
||||
## [v1.1.1](https://github.com/bcomnes/async-neocities/compare/v1.1.0...v1.1.1) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- bug: Fix busted export of stats handler. [`510ae29`](https://github.com/bcomnes/async-neocities/commit/510ae293263955e0e34d3ab48df253fb6e093053)
|
||||
|
||||
## [v1.1.0](https://github.com/bcomnes/async-neocities/compare/v1.0.2...v1.1.0) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- feat: Finish statsCb API and add a stats-handler.js function. [`c8e6483`](https://github.com/bcomnes/async-neocities/commit/c8e64835e594e68715ef71590b08baac374052bd)
|
||||
|
||||
## [v1.0.2](https://github.com/bcomnes/async-neocities/compare/v1.0.1...v1.0.2) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
- chore: remove total time from stats [`3c375ec`](https://github.com/bcomnes/async-neocities/commit/3c375ecf64ae8536a8e3ccce0a69cd93c8c6a306)
|
||||
|
||||
## [v1.0.1](https://github.com/bcomnes/async-neocities/compare/v1.0.0...v1.0.1) - 2020-02-13
|
||||
|
||||
### Commits
|
||||
|
||||
4
node_modules/async-neocities/README.md
generated
vendored
4
node_modules/async-neocities/README.md
generated
vendored
@@ -185,11 +185,11 @@ Deploy a path to a `directory`, efficiently only uploading missing and changed f
|
||||
```js
|
||||
{
|
||||
cleanup: false // delete orphaned files on neocities that are not in the `directory`
|
||||
statsCb: () => {} // WIP progress API
|
||||
statsCb: (stats) => {}
|
||||
}
|
||||
```
|
||||
|
||||
The return value of this method is subject to change.
|
||||
For an example of a stats handler, see [lib/stats-handler.js]('./lib/stats-handler.js').
|
||||
|
||||
### `client.get(endpoint, [quieries], [opts])`
|
||||
|
||||
|
||||
210
node_modules/async-neocities/index.js
generated
vendored
210
node_modules/async-neocities/index.js
generated
vendored
@@ -12,6 +12,7 @@ const { neocitiesLocalDiff } = require('./lib/folder-diff')
|
||||
const pkg = require('./package.json')
|
||||
const SimpleTimer = require('./lib/timer')
|
||||
const { getStreamLength, meterStream } = require('./lib/stream-meter')
|
||||
const statsHandler = require('./lib/stats-handler')
|
||||
|
||||
const defaultURL = 'https://neocities.org'
|
||||
|
||||
@@ -19,6 +20,7 @@ const defaultURL = 'https://neocities.org'
|
||||
const START = 'start'
|
||||
const PROGRESS = 'progress' // progress updates
|
||||
const STOP = 'stop'
|
||||
const SKIP = 'skip'
|
||||
// Progress stages
|
||||
const INSPECTING = 'inspecting'
|
||||
const DIFFING = 'diffing'
|
||||
@@ -55,6 +57,8 @@ class NeocitiesAPIClient {
|
||||
return fetch(url, opts)
|
||||
}
|
||||
|
||||
static statsHandler (...args) { return statsHandler(...args) }
|
||||
|
||||
/**
|
||||
* Create an async-neocities api client.
|
||||
* @param {string} apiKey An apiKey to make requests with.
|
||||
@@ -226,195 +230,73 @@ class NeocitiesAPIClient {
|
||||
}
|
||||
|
||||
const statsCb = opts.statsCb
|
||||
const startDeployTime = Date.now()
|
||||
const totalTime = new SimpleTimer(startDeployTime)
|
||||
const totalTime = new SimpleTimer(Date.now())
|
||||
|
||||
// Inspection stage stats initializer
|
||||
const inspectionStats = {
|
||||
stage: INSPECTING,
|
||||
status: START,
|
||||
timer: new SimpleTimer(startDeployTime),
|
||||
totalTime,
|
||||
tasks: {
|
||||
localScan: {
|
||||
numberOfFiles: 0,
|
||||
totalSize: 0,
|
||||
timer: new SimpleTimer(startDeployTime)
|
||||
},
|
||||
remoteScan: {
|
||||
numberOfFiles: 0,
|
||||
totalSize: 0,
|
||||
timer: new SimpleTimer(startDeployTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
const sendInspectionUpdate = (status) => {
|
||||
if (status) inspectionStats.status = status
|
||||
statsCb(inspectionStats)
|
||||
}
|
||||
sendInspectionUpdate(START)
|
||||
|
||||
// Remote scan timers
|
||||
const remoteScanJob = this.list()
|
||||
remoteScanJob.then(({ files }) => { // Comes in the form of a response object
|
||||
const { tasks: { remoteScan } } = inspectionStats
|
||||
remoteScan.numberOfFiles = files.length
|
||||
remoteScan.totalSize = files.reduce((accum, cur) => {
|
||||
return accum + cur.size || 0
|
||||
}, 0)
|
||||
remoteScan.timer.stop()
|
||||
sendInspectionUpdate(PROGRESS)
|
||||
})
|
||||
|
||||
// Local scan timers and progress accumulator
|
||||
const localScanJob = progressAccum(
|
||||
afw.asyncFolderWalker(directory, { shaper: f => f })
|
||||
)
|
||||
async function progressAccum (iterator) {
|
||||
const localFiles = []
|
||||
const { tasks: { localScan } } = inspectionStats
|
||||
|
||||
for await (const file of iterator) {
|
||||
localFiles.push(file)
|
||||
localScan.numberOfFiles += 1
|
||||
localScan.totalSize += file.stat.size
|
||||
sendInspectionUpdate(PROGRESS)
|
||||
}
|
||||
return localFiles
|
||||
}
|
||||
localScanJob.then(files => {
|
||||
const { tasks: { localScan } } = inspectionStats
|
||||
localScan.timer.stop()
|
||||
sendInspectionUpdate(PROGRESS)
|
||||
})
|
||||
|
||||
// Inspection stage finalizer
|
||||
// INSPECTION STAGE
|
||||
statsCb({ stage: INSPECTING, status: START })
|
||||
const [localFiles, remoteFiles] = await Promise.all([
|
||||
localScanJob,
|
||||
remoteScanJob.then(res => res.files)
|
||||
afw.allFiles(directory, { shaper: f => f }),
|
||||
this.list().then(res => res.files)
|
||||
])
|
||||
inspectionStats.timer.stop()
|
||||
sendInspectionUpdate(STOP)
|
||||
statsCb({ stage: INSPECTING, status: STOP })
|
||||
|
||||
// DIFFING STAGE
|
||||
|
||||
const diffingStats = {
|
||||
stage: DIFFING,
|
||||
status: START,
|
||||
timer: new SimpleTimer(Date.now()),
|
||||
totalTime,
|
||||
tasks: {
|
||||
diffing: {
|
||||
uploadCount: 0,
|
||||
deleteCount: 0,
|
||||
skipCount: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
statsCb(diffingStats)
|
||||
|
||||
const { tasks: { diffing } } = diffingStats
|
||||
statsCb({ stage: DIFFING, status: START })
|
||||
const { filesToUpload, filesToDelete, filesSkipped } = await neocitiesLocalDiff(remoteFiles, localFiles)
|
||||
statsCb({ stage: DIFFING, status: STOP })
|
||||
|
||||
diffingStats.timer.stop()
|
||||
diffingStats.status = STOP
|
||||
diffing.uploadCount = filesToUpload.length
|
||||
diffing.deleteCount = filesToDelete.length
|
||||
diffing.skipCount = filesSkipped.length
|
||||
statsCb(diffingStats)
|
||||
|
||||
const applyingStartTime = Date.now()
|
||||
const applyingStats = {
|
||||
stage: APPLYING,
|
||||
status: START,
|
||||
timer: new SimpleTimer(applyingStartTime),
|
||||
totalTime,
|
||||
tasks: {
|
||||
uploadFiles: {
|
||||
timer: new SimpleTimer(applyingStartTime),
|
||||
bytesWritten: 0,
|
||||
totalBytes: 0,
|
||||
get percent () {
|
||||
return this.totalBytes === 0 ? 0 : this.bytesWritten / this.totalBytes
|
||||
},
|
||||
get speed () {
|
||||
return this.bytesWritten / this.timer.elapsed
|
||||
}
|
||||
},
|
||||
deleteFiles: {
|
||||
timer: new SimpleTimer(applyingStartTime),
|
||||
bytesWritten: 0,
|
||||
totalBytes: 0,
|
||||
get percent () {
|
||||
return this.totalBytes === 0 ? 0 : this.bytesWritten / this.totalBytes
|
||||
},
|
||||
get speed () {
|
||||
return this.bytesWritten / this.timer.elapsed
|
||||
}
|
||||
},
|
||||
skippedFiles: {
|
||||
count: filesSkipped.length,
|
||||
size: filesSkipped.reduce((accum, file) => accum + file.stat.size, 0)
|
||||
}
|
||||
}
|
||||
// APPLYING STAGE
|
||||
if (filesToUpload.length === 0 && (!opts.cleanup || filesToDelete.length === 0)) {
|
||||
statsCb({ stage: APPLYING, status: SKIP })
|
||||
return stats()
|
||||
}
|
||||
const sendApplyingUpdate = (status) => {
|
||||
if (status) applyingStats.status = status
|
||||
statsCb(applyingStats)
|
||||
}
|
||||
sendApplyingUpdate(START)
|
||||
|
||||
statsCb({ stage: APPLYING, status: START })
|
||||
const work = []
|
||||
const { tasks: { uploadFiles, deleteFiles } } = applyingStats
|
||||
|
||||
if (filesToUpload.length > 0) {
|
||||
const uploadJob = this.upload(filesToUpload, {
|
||||
statsCb: ({ bytesWritten, totalBytes }) => {
|
||||
uploadFiles.bytesWritten = bytesWritten
|
||||
uploadFiles.totalBytes = totalBytes
|
||||
sendApplyingUpdate(PROGRESS)
|
||||
statsCb ({ totalBytes, bytesWritten }) {
|
||||
statsCb({
|
||||
stage: APPLYING,
|
||||
status: PROGRESS,
|
||||
complete: false,
|
||||
totalBytes,
|
||||
bytesWritten,
|
||||
get progress () {
|
||||
return (this.bytesWritten / this.totalBytes) || 0
|
||||
}
|
||||
})
|
||||
}
|
||||
}).then((_) => {
|
||||
statsCb({
|
||||
stage: APPLYING,
|
||||
status: PROGRESS,
|
||||
complete: true,
|
||||
progress: 1.0
|
||||
})
|
||||
})
|
||||
work.push(uploadJob)
|
||||
uploadJob.then(res => {
|
||||
uploadFiles.timer.stop()
|
||||
sendApplyingUpdate(PROGRESS)
|
||||
})
|
||||
} else {
|
||||
uploadFiles.timer.stop()
|
||||
}
|
||||
|
||||
if (opts.cleanup && filesToDelete.length > 0) {
|
||||
const deleteJob = this.delete(filesToDelete, {
|
||||
statsCb: ({ bytesWritten, totalBytes }) => {
|
||||
deleteFiles.bytesWritten = bytesWritten
|
||||
deleteFiles.totalBytes = totalBytes
|
||||
sendApplyingUpdate(PROGRESS)
|
||||
}
|
||||
})
|
||||
work.push(deleteJob)
|
||||
deleteJob.then(res => {
|
||||
deleteFiles.timer.stop()
|
||||
sendApplyingUpdate(PROGRESS)
|
||||
})
|
||||
} else {
|
||||
deleteFiles.timer.stop()
|
||||
work.push(this.delete(filesToDelete))
|
||||
}
|
||||
|
||||
await Promise.all(work)
|
||||
applyingStats.timer.stop()
|
||||
sendApplyingUpdate(STOP)
|
||||
statsCb({ stage: APPLYING, status: STOP })
|
||||
|
||||
totalTime.stop()
|
||||
return stats()
|
||||
|
||||
const statsSummary = {
|
||||
time: totalTime,
|
||||
inspectionStats,
|
||||
diffingStats,
|
||||
applyingStats
|
||||
function stats () {
|
||||
totalTime.stop()
|
||||
return {
|
||||
time: totalTime.elapsed,
|
||||
filesToUpload,
|
||||
filesToDelete,
|
||||
filesSkipped
|
||||
}
|
||||
}
|
||||
|
||||
return statsSummary
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
60
node_modules/async-neocities/lib/stats-handler.js
generated
vendored
Normal file
60
node_modules/async-neocities/lib/stats-handler.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
const prettyBytes = require('pretty-bytes')
|
||||
|
||||
// Progress API constants
|
||||
const START = 'start'
|
||||
const PROGRESS = 'progress' // progress updates
|
||||
const STOP = 'stop'
|
||||
const SKIP = 'skip'
|
||||
|
||||
function statsHandler (opts = {}) {
|
||||
let progressInterval
|
||||
const lastStats = {}
|
||||
|
||||
return (stats) => {
|
||||
switch (stats.status) {
|
||||
case START: {
|
||||
console.log(`Starting ${stats.stage} stage...`)
|
||||
break
|
||||
}
|
||||
case STOP: {
|
||||
console.log(`Finished ${stats.stage} stage.`)
|
||||
break
|
||||
}
|
||||
case SKIP: {
|
||||
console.log(`Skipping ${stats.stage} stage.`)
|
||||
break
|
||||
}
|
||||
case PROGRESS: {
|
||||
progressHandler(stats)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function progressHandler (stats) {
|
||||
Object.assign(lastStats, stats)
|
||||
if (!stats.complete && stats.progress < 1) {
|
||||
if (!progressInterval) {
|
||||
progressInterval = setInterval(logProgress, 500, lastStats)
|
||||
logProgress(lastStats)
|
||||
}
|
||||
} else {
|
||||
if (progressInterval) {
|
||||
clearInterval(progressInterval)
|
||||
logProgress(lastStats)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function logProgress (stats) {
|
||||
let logLine = `Stage ${stats.stage}: ${(stats.progress * 100).toFixed(2)}%`
|
||||
if (stats.bytesWritten != null && stats.totalBytes != null) {
|
||||
logLine = logLine + ` (${prettyBytes(stats.bytesWritten)} / ${prettyBytes(stats.totalBytes)})`
|
||||
}
|
||||
console.log(logLine)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = statsHandler
|
||||
21
node_modules/async-neocities/package.json
generated
vendored
21
node_modules/async-neocities/package.json
generated
vendored
@@ -1,26 +1,26 @@
|
||||
{
|
||||
"_from": "async-neocities@1.0.1",
|
||||
"_id": "async-neocities@1.0.1",
|
||||
"_from": "async-neocities@1.1.6",
|
||||
"_id": "async-neocities@1.1.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-5TVaKLYKnaHoSiluCP0i78e0CBZbeqBL6bgK8/QsM8YOAtrhd5JO9c5DEaW4SFpmf4wV0qcamQXh0A3C7CANLw==",
|
||||
"_integrity": "sha512-q5fTVttBaN9znGxqxxDAh/ks+bZngIJPu6zPS7nlbJLC9NnOhrcP5Mu0VntxgEBtAuaExyI6uH/C+CxKSW0LeQ==",
|
||||
"_location": "/async-neocities",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "async-neocities@1.0.1",
|
||||
"raw": "async-neocities@1.1.6",
|
||||
"name": "async-neocities",
|
||||
"escapedName": "async-neocities",
|
||||
"rawSpec": "1.0.1",
|
||||
"rawSpec": "1.1.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.1"
|
||||
"fetchSpec": "1.1.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/async-neocities/-/async-neocities-1.0.1.tgz",
|
||||
"_shasum": "3428ae48f48104b205a3537212090b00d9bbce45",
|
||||
"_spec": "async-neocities@1.0.1",
|
||||
"_resolved": "https://registry.npmjs.org/async-neocities/-/async-neocities-1.1.6.tgz",
|
||||
"_shasum": "405b45565ccbe9c4ea56e65552ae9c48c20a0309",
|
||||
"_spec": "async-neocities@1.1.6",
|
||||
"_where": "/Users/bret/repos/deploy-to-neocities",
|
||||
"author": {
|
||||
"name": "Bret Comnes",
|
||||
@@ -37,6 +37,7 @@
|
||||
"form-data": "^3.0.0",
|
||||
"nanoassert": "^2.0.0",
|
||||
"node-fetch": "^2.6.0",
|
||||
"pretty-bytes": "^5.3.0",
|
||||
"pump": "^3.0.0",
|
||||
"pumpify": "^2.0.1",
|
||||
"qs": "^6.9.1",
|
||||
@@ -79,5 +80,5 @@
|
||||
"dist"
|
||||
]
|
||||
},
|
||||
"version": "1.0.1"
|
||||
"version": "1.1.6"
|
||||
}
|
||||
|
||||
15
node_modules/async-neocities/test.js
generated
vendored
15
node_modules/async-neocities/test.js
generated
vendored
@@ -3,6 +3,7 @@ const tap = require('tap')
|
||||
const { readFileSync } = require('fs')
|
||||
const { resolve } = require('path')
|
||||
const NeocitiesAPIClient = require('.')
|
||||
const statsHanlder = require('./lib/stats-handler')
|
||||
|
||||
let token = process.env.NEOCITIES_API_TOKEN
|
||||
let fakeToken = false
|
||||
@@ -87,18 +88,10 @@ if (!fakeToken) {
|
||||
tap.test('can deploy folders', async t => {
|
||||
const client = new NeocitiesAPIClient(token)
|
||||
|
||||
const statsCb = (stats) => {
|
||||
let logLine = `${stats.stage} ${stats.status} ${stats.timer.elapsed}`
|
||||
Object.entries(stats.tasks).forEach(([key, val]) => {
|
||||
logLine += ` ${key}: ${JSON.stringify(val)}`
|
||||
})
|
||||
console.log(logLine)
|
||||
}
|
||||
|
||||
const deployStats = await client.deploy(
|
||||
resolve(__dirname, 'fixtures'),
|
||||
{
|
||||
statsCb,
|
||||
statsCb: statsHanlder(),
|
||||
cleanup: false
|
||||
}
|
||||
)
|
||||
@@ -110,7 +103,7 @@ if (!fakeToken) {
|
||||
const redeployStats = await client.deploy(
|
||||
resolve(__dirname, 'fixtures'),
|
||||
{
|
||||
statsCb,
|
||||
statsCb: statsHanlder(),
|
||||
cleanup: false
|
||||
}
|
||||
)
|
||||
@@ -122,7 +115,7 @@ if (!fakeToken) {
|
||||
const cleanupStats = await client.deploy(
|
||||
resolve(__dirname, 'fixtures/empty'),
|
||||
{
|
||||
statsCb,
|
||||
statsCb: statsHanlder(),
|
||||
cleanup: true
|
||||
}
|
||||
)
|
||||
|
||||
162
node_modules/ms/index.js
generated
vendored
Normal file
162
node_modules/ms/index.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var w = d * 7;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isFinite(val)) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
throw new Error(
|
||||
'val is not a non-empty string or a valid number. val=' +
|
||||
JSON.stringify(val)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||
str
|
||||
);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'w':
|
||||
return n * w;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return plural(ms, msAbs, d, 'day');
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return plural(ms, msAbs, h, 'hour');
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return plural(ms, msAbs, m, 'minute');
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return plural(ms, msAbs, s, 'second');
|
||||
}
|
||||
return ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, msAbs, n, name) {
|
||||
var isPlural = msAbs >= n * 1.5;
|
||||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||
}
|
||||
10
node_modules/pretty-time/LICENSE → node_modules/ms/license.md
generated
vendored
10
node_modules/pretty-time/LICENSE → node_modules/ms/license.md
generated
vendored
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present, Jon Schlinkert.
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
70
node_modules/ms/package.json
generated
vendored
Normal file
70
node_modules/ms/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"_from": "ms@^2.1.2",
|
||||
"_id": "ms@2.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"_location": "/ms",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "ms@^2.1.2",
|
||||
"name": "ms",
|
||||
"escapedName": "ms",
|
||||
"rawSpec": "^2.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/",
|
||||
"/debug"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"_shasum": "d09d1f357b443f493382a8eb3ccd183872ae6009",
|
||||
"_spec": "ms@^2.1.2",
|
||||
"_where": "/Users/bret/repos/deploy-to-neocities",
|
||||
"bugs": {
|
||||
"url": "https://github.com/zeit/ms/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Tiny millisecond conversion utility",
|
||||
"devDependencies": {
|
||||
"eslint": "4.12.1",
|
||||
"expect.js": "0.3.1",
|
||||
"husky": "0.14.3",
|
||||
"lint-staged": "5.0.0",
|
||||
"mocha": "4.0.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/zeit/ms#readme",
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run lint",
|
||||
"prettier --single-quote --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "./index",
|
||||
"name": "ms",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/zeit/ms.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint lib/* bin/*",
|
||||
"precommit": "lint-staged",
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"version": "2.1.2"
|
||||
}
|
||||
60
node_modules/ms/readme.md
generated
vendored
Normal file
60
node_modules/ms/readme.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://spectrum.chat/zeit)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
ms('-3 days') // -259200000
|
||||
ms('-1h') // -3600000
|
||||
ms('-200') // -200
|
||||
```
|
||||
|
||||
### Convert from Milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(-3 * 60000) // "-3m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time Format Written-Out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(-3 * 60000, { long: true }) // "-3 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [Node.js](https://nodejs.org) and in the browser
|
||||
- If a number is supplied to `ms`, a string with a unit is returned
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
|
||||
|
||||
## Related Packages
|
||||
|
||||
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
|
||||
|
||||
## Caught a Bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
||||
4
node_modules/pretty-bytes/package.json
generated
vendored
4
node_modules/pretty-bytes/package.json
generated
vendored
@@ -16,12 +16,12 @@
|
||||
"fetchSpec": "^5.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
"/async-neocities"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz",
|
||||
"_shasum": "f2849e27db79fb4d6cfe24764fc4134f165989f2",
|
||||
"_spec": "pretty-bytes@^5.3.0",
|
||||
"_where": "/Users/bret/repos/deploy-to-neocities",
|
||||
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/async-neocities",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
|
||||
169
node_modules/pretty-time/README.md
generated
vendored
169
node_modules/pretty-time/README.md
generated
vendored
@@ -1,169 +0,0 @@
|
||||
# pretty-time [](https://www.npmjs.com/package/pretty-time) [](https://npmjs.org/package/pretty-time) [](https://npmjs.org/package/pretty-time) [](https://travis-ci.org/jonschlinkert/pretty-time)
|
||||
|
||||
> Easily format the time from node.js `process.hrtime`. Works with timescales ranging from weeks to nanoseconds.
|
||||
|
||||
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save pretty-time
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var pretty = require('pretty-time');
|
||||
|
||||
var start = process.hrtime();
|
||||
var time = process.hrtime(start);
|
||||
console.log(pretty(time));
|
||||
//=> 3μs
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
By default, when no time increment is given as the second argument, the closest timescale is used (e.g. _most granular without being less than zero_).
|
||||
|
||||
**Examples:**
|
||||
|
||||
```js
|
||||
pretty([1200708, 795428088]);
|
||||
//=> '2w'
|
||||
|
||||
pretty([800708, 795428088]);
|
||||
//=> '1w'
|
||||
|
||||
pretty([400708, 795428088]);
|
||||
//=> '5d'
|
||||
|
||||
pretty([70708, 795428088]);
|
||||
//=> '20h'
|
||||
|
||||
pretty([12708, 795428088]);
|
||||
//=> '4h'
|
||||
|
||||
pretty([3708, 795428088]);
|
||||
//=> '1h'
|
||||
|
||||
pretty([208, 795428088]);
|
||||
//=> '3m'
|
||||
|
||||
pretty([20, 795428088]);
|
||||
//=> '21s'
|
||||
|
||||
pretty([0, 795428088]);
|
||||
//=> '795ms'
|
||||
|
||||
pretty([0, 000428088]);
|
||||
//=> '428μs'
|
||||
|
||||
pretty([0, 000000088]);
|
||||
//=> '88ns'
|
||||
|
||||
pretty([0, 000000018]);
|
||||
//=> '18ns'
|
||||
```
|
||||
|
||||
### Minimum time increment
|
||||
|
||||
_(All of the following examples use `[6740, 795428088]` as the hrtime array.)_
|
||||
|
||||
This value is passed as the second argument and determines how granular to make the time.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
pretty(time, 'h');
|
||||
//=> '2h'
|
||||
|
||||
pretty(time, 'm');
|
||||
//=> '1h 52m'
|
||||
|
||||
pretty(time, 's');
|
||||
//=> '1h 52m 21s'
|
||||
```
|
||||
|
||||
**Valid time increments**
|
||||
|
||||
Any of the following may be used:
|
||||
|
||||
* `ns` | `nano` | `nanosecond` | `nanoseconds`
|
||||
* `μs` | `micro` | `microsecond` | `microseconds`
|
||||
* `ms` | `milli` | `millisecond` | `milliseconds`
|
||||
* `s` | `sec` | `second` | `seconds`
|
||||
* `m` | `min` | `minute` | `minutes`
|
||||
* `h` | `hr` | `hour` | `hours`
|
||||
* `d` | `day` | `days`
|
||||
* `w` | `wk` | `week` | `weeks`
|
||||
|
||||
## About
|
||||
|
||||
<details>
|
||||
<summary><strong>Contributing</strong></summary>
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Running Tests</strong></summary>
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Building docs</strong></summary>
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Related projects
|
||||
|
||||
You might also be interested in these projects:
|
||||
|
||||
* [o-clock](https://www.npmjs.com/package/o-clock): Simple javascript utility for displaying the time in 12-hour clock format. | [homepage](https://github.com/jonschlinkert/o-clock "Simple javascript utility for displaying the time in 12-hour clock format.")
|
||||
* [seconds](https://www.npmjs.com/package/seconds): Get the number of seconds for a minute, hour, day and week. | [homepage](https://github.com/jonschlinkert/seconds "Get the number of seconds for a minute, hour, day and week.")
|
||||
* [time-stamp](https://www.npmjs.com/package/time-stamp): Get a formatted timestamp. | [homepage](https://github.com/jonschlinkert/time-stamp "Get a formatted timestamp.")
|
||||
* [timescale](https://www.npmjs.com/package/timescale): Convert from one time scale to another. Nanosecond is the most atomic unit, week is… [more](https://github.com/jonschlinkert/timescale) | [homepage](https://github.com/jonschlinkert/timescale "Convert from one time scale to another. Nanosecond is the most atomic unit, week is the largest unit.")
|
||||
* [week](https://www.npmjs.com/package/week): Get the current week number. | [homepage](https://github.com/datetime/week "Get the current week number.")
|
||||
* [weekday](https://www.npmjs.com/package/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://github.com/datetime/weekday) | [homepage](https://github.com/datetime/weekday "Get the name and number of the current weekday. Or get the name of the weekday for a given number.")
|
||||
* [year](https://www.npmjs.com/package/year): Simple utility to get the current year with 2 or 4 digits. | [homepage](https://github.com/jonschlinkert/year "Simple utility to get the current year with 2 or 4 digits.")
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 14 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 5 | [doowb](https://github.com/doowb) |
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||
* [GitHub Profile](https://github.com/jonschlinkert)
|
||||
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 12, 2018._
|
||||
56
node_modules/pretty-time/index.js
generated
vendored
56
node_modules/pretty-time/index.js
generated
vendored
@@ -1,56 +0,0 @@
|
||||
/*!
|
||||
* pretty-time <https://github.com/jonschlinkert/pretty-time>
|
||||
*
|
||||
* Copyright (c) 2015-2018, present, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = (time, smallest, digits) => {
|
||||
const isNumber = /^[0-9]+$/.test(time);
|
||||
if (!isNumber && !Array.isArray(time)) {
|
||||
throw new TypeError('expected an array or number in nanoseconds');
|
||||
}
|
||||
if (Array.isArray(time) && time.length !== 2) {
|
||||
throw new TypeError('expected an array from process.hrtime()');
|
||||
}
|
||||
|
||||
if (/^[0-9]+$/.test(smallest)) {
|
||||
digits = smallest;
|
||||
smallest = null;
|
||||
}
|
||||
|
||||
let num = isNumber ? time : utils.nano(time);
|
||||
let res = '';
|
||||
let prev;
|
||||
|
||||
for (const uom of Object.keys(utils.scale)) {
|
||||
const step = utils.scale[uom];
|
||||
let inc = num / step;
|
||||
|
||||
if (smallest && utils.isSmallest(uom, smallest)) {
|
||||
inc = utils.round(inc, digits);
|
||||
if (prev && (inc === (prev / step))) --inc;
|
||||
res += inc + uom;
|
||||
return res.trim();
|
||||
}
|
||||
|
||||
if (inc < 1) continue;
|
||||
if (!smallest) {
|
||||
inc = utils.round(inc, digits);
|
||||
res += inc + uom;
|
||||
return res;
|
||||
}
|
||||
|
||||
prev = step;
|
||||
|
||||
inc = Math.floor(inc);
|
||||
num -= (inc * step);
|
||||
res += inc + uom + ' ';
|
||||
}
|
||||
|
||||
return res.trim();
|
||||
};
|
||||
99
node_modules/pretty-time/package.json
generated
vendored
99
node_modules/pretty-time/package.json
generated
vendored
@@ -1,99 +0,0 @@
|
||||
{
|
||||
"_from": "pretty-time@^1.1.0",
|
||||
"_id": "pretty-time@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-28iF6xPQrP8Oa6uxE6a1biz+lWeTOAPKggvjB8HAs6nVMKZwf5bG++632Dx614hIWgUPkgivRfG+a8uAXGTIbA==",
|
||||
"_location": "/pretty-time",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "pretty-time@^1.1.0",
|
||||
"name": "pretty-time",
|
||||
"escapedName": "pretty-time",
|
||||
"rawSpec": "^1.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pretty-time/-/pretty-time-1.1.0.tgz",
|
||||
"_shasum": "ffb7429afabb8535c346a34e41873adf3d74dd0e",
|
||||
"_spec": "pretty-time@^1.1.0",
|
||||
"_where": "/Users/bret/repos/deploy-to-neocities",
|
||||
"author": {
|
||||
"name": "Jon Schlinkert",
|
||||
"url": "https://github.com/jonschlinkert"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/pretty-time/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Easily format the time from node.js `process.hrtime`. Works with timescales ranging from weeks to nanoseconds.",
|
||||
"devDependencies": {
|
||||
"gulp-format-md": "^1.0.0",
|
||||
"mocha": "^3.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"utils.js"
|
||||
],
|
||||
"homepage": "https://github.com/jonschlinkert/pretty-time",
|
||||
"keywords": [
|
||||
"convert",
|
||||
"date",
|
||||
"format",
|
||||
"formatting",
|
||||
"hour",
|
||||
"hrtime",
|
||||
"micro",
|
||||
"milli",
|
||||
"minute",
|
||||
"nano",
|
||||
"nanosecond",
|
||||
"pretty",
|
||||
"second",
|
||||
"time",
|
||||
"week"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "pretty-time",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jonschlinkert/pretty-time.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"o-clock",
|
||||
"seconds",
|
||||
"time-stamp",
|
||||
"timescale",
|
||||
"week",
|
||||
"weekday",
|
||||
"year"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
32
node_modules/pretty-time/utils.js
generated
vendored
32
node_modules/pretty-time/utils.js
generated
vendored
@@ -1,32 +0,0 @@
|
||||
exports.nano = time => +time[0] * 1e9 + +time[1];
|
||||
|
||||
exports.scale = {
|
||||
'w': 6048e11,
|
||||
'd': 864e11,
|
||||
'h': 36e11,
|
||||
'm': 6e10,
|
||||
's': 1e9,
|
||||
'ms': 1e6,
|
||||
'μs': 1e3,
|
||||
'ns': 1,
|
||||
};
|
||||
|
||||
exports.regex = {
|
||||
'w': /^(w((ee)?k)?s?)$/,
|
||||
'd': /^(d(ay)?s?)$/,
|
||||
'h': /^(h((ou)?r)?s?)$/,
|
||||
'm': /^(min(ute)?s?|m)$/,
|
||||
's': /^((sec(ond)?)s?|s)$/,
|
||||
'ms': /^(milli(second)?s?|ms)$/,
|
||||
'μs': /^(micro(second)?s?|μs)$/,
|
||||
'ns': /^(nano(second)?s?|ns?)$/,
|
||||
};
|
||||
|
||||
exports.isSmallest = function(uom, unit) {
|
||||
return exports.regex[uom].test(unit);
|
||||
};
|
||||
|
||||
exports.round = function(num, digits) {
|
||||
const n = Math.abs(num);
|
||||
return /[0-9]/.test(digits) ? n.toFixed(digits) : Math.round(n);
|
||||
};
|
||||
2
node_modules/readable-stream/README.md
generated
vendored
2
node_modules/readable-stream/README.md
generated
vendored
@@ -15,7 +15,7 @@ npm install --save readable-stream
|
||||
|
||||
This package is a mirror of the streams implementations in Node.js.
|
||||
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.18.1/docs/api/stream.html).
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.19.0/docs/api/stream.html).
|
||||
|
||||
If you want to guarantee a stable streams base, regardless of what version of
|
||||
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
|
||||
|
||||
311
node_modules/readable-stream/lib/internal/streams/buffer_list.js
generated
vendored
311
node_modules/readable-stream/lib/internal/streams/buffer_list.js
generated
vendored
@@ -6,6 +6,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
var _require = require('buffer'),
|
||||
Buffer = _require.Buffer;
|
||||
|
||||
@@ -22,170 +28,183 @@ module.exports =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function BufferList() {
|
||||
_classCallCheck(this, BufferList);
|
||||
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
var _proto = BufferList.prototype;
|
||||
|
||||
_proto.push = function push(v) {
|
||||
var entry = {
|
||||
data: v,
|
||||
next: null
|
||||
};
|
||||
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
||||
this.tail = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
_proto.unshift = function unshift(v) {
|
||||
var entry = {
|
||||
data: v,
|
||||
next: this.head
|
||||
};
|
||||
if (this.length === 0) this.tail = entry;
|
||||
this.head = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
_proto.shift = function shift() {
|
||||
if (this.length === 0) return;
|
||||
var ret = this.head.data;
|
||||
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
||||
--this.length;
|
||||
return ret;
|
||||
};
|
||||
|
||||
_proto.clear = function clear() {
|
||||
this.head = this.tail = null;
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
_proto.join = function join(s) {
|
||||
if (this.length === 0) return '';
|
||||
var p = this.head;
|
||||
var ret = '' + p.data;
|
||||
|
||||
while (p = p.next) {
|
||||
ret += s + p.data;
|
||||
_createClass(BufferList, [{
|
||||
key: "push",
|
||||
value: function push(v) {
|
||||
var entry = {
|
||||
data: v,
|
||||
next: null
|
||||
};
|
||||
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
||||
this.tail = entry;
|
||||
++this.length;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
_proto.concat = function concat(n) {
|
||||
if (this.length === 0) return Buffer.alloc(0);
|
||||
var ret = Buffer.allocUnsafe(n >>> 0);
|
||||
var p = this.head;
|
||||
var i = 0;
|
||||
|
||||
while (p) {
|
||||
copyBuffer(p.data, ret, i);
|
||||
i += p.data.length;
|
||||
p = p.next;
|
||||
}, {
|
||||
key: "unshift",
|
||||
value: function unshift(v) {
|
||||
var entry = {
|
||||
data: v,
|
||||
next: this.head
|
||||
};
|
||||
if (this.length === 0) this.tail = entry;
|
||||
this.head = entry;
|
||||
++this.length;
|
||||
}
|
||||
|
||||
return ret;
|
||||
} // Consumes a specified amount of bytes or characters from the buffered data.
|
||||
;
|
||||
|
||||
_proto.consume = function consume(n, hasStrings) {
|
||||
var ret;
|
||||
|
||||
if (n < this.head.data.length) {
|
||||
// `slice` is the same for buffers and strings.
|
||||
ret = this.head.data.slice(0, n);
|
||||
this.head.data = this.head.data.slice(n);
|
||||
} else if (n === this.head.data.length) {
|
||||
// First chunk is a perfect match.
|
||||
ret = this.shift();
|
||||
} else {
|
||||
// Result spans more than one buffer.
|
||||
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
|
||||
}, {
|
||||
key: "shift",
|
||||
value: function shift() {
|
||||
if (this.length === 0) return;
|
||||
var ret = this.head.data;
|
||||
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
||||
--this.length;
|
||||
return ret;
|
||||
}
|
||||
}, {
|
||||
key: "clear",
|
||||
value: function clear() {
|
||||
this.head = this.tail = null;
|
||||
this.length = 0;
|
||||
}
|
||||
}, {
|
||||
key: "join",
|
||||
value: function join(s) {
|
||||
if (this.length === 0) return '';
|
||||
var p = this.head;
|
||||
var ret = '' + p.data;
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
_proto.first = function first() {
|
||||
return this.head.data;
|
||||
} // Consumes a specified amount of characters from the buffered data.
|
||||
;
|
||||
|
||||
_proto._getString = function _getString(n) {
|
||||
var p = this.head;
|
||||
var c = 1;
|
||||
var ret = p.data;
|
||||
n -= ret.length;
|
||||
|
||||
while (p = p.next) {
|
||||
var str = p.data;
|
||||
var nb = n > str.length ? str.length : n;
|
||||
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
||||
n -= nb;
|
||||
|
||||
if (n === 0) {
|
||||
if (nb === str.length) {
|
||||
++c;
|
||||
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
||||
} else {
|
||||
this.head = p;
|
||||
p.data = str.slice(nb);
|
||||
}
|
||||
|
||||
break;
|
||||
while (p = p.next) {
|
||||
ret += s + p.data;
|
||||
}
|
||||
|
||||
++c;
|
||||
return ret;
|
||||
}
|
||||
}, {
|
||||
key: "concat",
|
||||
value: function concat(n) {
|
||||
if (this.length === 0) return Buffer.alloc(0);
|
||||
var ret = Buffer.allocUnsafe(n >>> 0);
|
||||
var p = this.head;
|
||||
var i = 0;
|
||||
|
||||
this.length -= c;
|
||||
return ret;
|
||||
} // Consumes a specified amount of bytes from the buffered data.
|
||||
;
|
||||
|
||||
_proto._getBuffer = function _getBuffer(n) {
|
||||
var ret = Buffer.allocUnsafe(n);
|
||||
var p = this.head;
|
||||
var c = 1;
|
||||
p.data.copy(ret);
|
||||
n -= p.data.length;
|
||||
|
||||
while (p = p.next) {
|
||||
var buf = p.data;
|
||||
var nb = n > buf.length ? buf.length : n;
|
||||
buf.copy(ret, ret.length - n, 0, nb);
|
||||
n -= nb;
|
||||
|
||||
if (n === 0) {
|
||||
if (nb === buf.length) {
|
||||
++c;
|
||||
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
||||
} else {
|
||||
this.head = p;
|
||||
p.data = buf.slice(nb);
|
||||
}
|
||||
|
||||
break;
|
||||
while (p) {
|
||||
copyBuffer(p.data, ret, i);
|
||||
i += p.data.length;
|
||||
p = p.next;
|
||||
}
|
||||
|
||||
++c;
|
||||
return ret;
|
||||
} // Consumes a specified amount of bytes or characters from the buffered data.
|
||||
|
||||
}, {
|
||||
key: "consume",
|
||||
value: function consume(n, hasStrings) {
|
||||
var ret;
|
||||
|
||||
if (n < this.head.data.length) {
|
||||
// `slice` is the same for buffers and strings.
|
||||
ret = this.head.data.slice(0, n);
|
||||
this.head.data = this.head.data.slice(n);
|
||||
} else if (n === this.head.data.length) {
|
||||
// First chunk is a perfect match.
|
||||
ret = this.shift();
|
||||
} else {
|
||||
// Result spans more than one buffer.
|
||||
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}, {
|
||||
key: "first",
|
||||
value: function first() {
|
||||
return this.head.data;
|
||||
} // Consumes a specified amount of characters from the buffered data.
|
||||
|
||||
this.length -= c;
|
||||
return ret;
|
||||
} // Make sure the linked list only shows the minimal necessary information.
|
||||
;
|
||||
}, {
|
||||
key: "_getString",
|
||||
value: function _getString(n) {
|
||||
var p = this.head;
|
||||
var c = 1;
|
||||
var ret = p.data;
|
||||
n -= ret.length;
|
||||
|
||||
_proto[custom] = function (_, options) {
|
||||
return inspect(this, _objectSpread({}, options, {
|
||||
// Only inspect one level.
|
||||
depth: 0,
|
||||
// It should not recurse.
|
||||
customInspect: false
|
||||
}));
|
||||
};
|
||||
while (p = p.next) {
|
||||
var str = p.data;
|
||||
var nb = n > str.length ? str.length : n;
|
||||
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
||||
n -= nb;
|
||||
|
||||
if (n === 0) {
|
||||
if (nb === str.length) {
|
||||
++c;
|
||||
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
||||
} else {
|
||||
this.head = p;
|
||||
p.data = str.slice(nb);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
++c;
|
||||
}
|
||||
|
||||
this.length -= c;
|
||||
return ret;
|
||||
} // Consumes a specified amount of bytes from the buffered data.
|
||||
|
||||
}, {
|
||||
key: "_getBuffer",
|
||||
value: function _getBuffer(n) {
|
||||
var ret = Buffer.allocUnsafe(n);
|
||||
var p = this.head;
|
||||
var c = 1;
|
||||
p.data.copy(ret);
|
||||
n -= p.data.length;
|
||||
|
||||
while (p = p.next) {
|
||||
var buf = p.data;
|
||||
var nb = n > buf.length ? buf.length : n;
|
||||
buf.copy(ret, ret.length - n, 0, nb);
|
||||
n -= nb;
|
||||
|
||||
if (n === 0) {
|
||||
if (nb === buf.length) {
|
||||
++c;
|
||||
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
||||
} else {
|
||||
this.head = p;
|
||||
p.data = buf.slice(nb);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
++c;
|
||||
}
|
||||
|
||||
this.length -= c;
|
||||
return ret;
|
||||
} // Make sure the linked list only shows the minimal necessary information.
|
||||
|
||||
}, {
|
||||
key: custom,
|
||||
value: function value(_, options) {
|
||||
return inspect(this, _objectSpread({}, options, {
|
||||
// Only inspect one level.
|
||||
depth: 0,
|
||||
// It should not recurse.
|
||||
customInspect: false
|
||||
}));
|
||||
}
|
||||
}]);
|
||||
|
||||
return BufferList;
|
||||
}();
|
||||
10
node_modules/readable-stream/package.json
generated
vendored
10
node_modules/readable-stream/package.json
generated
vendored
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"_from": "readable-stream@^3.1.1",
|
||||
"_id": "readable-stream@3.5.0",
|
||||
"_id": "readable-stream@3.6.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==",
|
||||
"_integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
|
||||
"_location": "/readable-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
@@ -18,8 +18,8 @@
|
||||
"_requiredBy": [
|
||||
"/duplexify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz",
|
||||
"_shasum": "465d70e6d1087f6162d079cd0b5db7fbebfd1606",
|
||||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
"_shasum": "337bbda3adc0706bd3e024426a286d4b4b2c9198",
|
||||
"_spec": "readable-stream@^3.1.1",
|
||||
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/duplexify",
|
||||
"browser": {
|
||||
@@ -93,5 +93,5 @@
|
||||
"test-browsers": "airtap --sauce-connect --loopback airtap.local -- test/browser.js",
|
||||
"update-browser-errors": "babel -o errors-browser.js errors.js"
|
||||
},
|
||||
"version": "3.5.0"
|
||||
"version": "3.6.0"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "deploy-to-neocities",
|
||||
"version": "0.0.3",
|
||||
"version": "1.0.0",
|
||||
"description": "Github Action to deplpoy a folder to Neocities.org",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
@@ -39,9 +39,8 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "1.2.2",
|
||||
"@actions/github": "2.1.0",
|
||||
"async-neocities": "1.0.1",
|
||||
"pretty-bytes": "^5.3.0",
|
||||
"pretty-time": "^1.1.0"
|
||||
"async-neocities": "1.1.6",
|
||||
"ms": "^2.1.2"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
|
||||
Reference in New Issue
Block a user