Skip to content

Commit

Permalink
WIP: convert to typescript; esm failing as TaskGroup needs to become …
Browse files Browse the repository at this point in the history
…TypeScript
  • Loading branch information
balupton committed Jan 3, 2024
1 parent f63a0f6 commit 7fbe68c
Show file tree
Hide file tree
Showing 16 changed files with 3,197 additions and 6,806 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 2018 September 26
# 2023 June 22
# https://github.com/bevry/base

root = true
Expand All @@ -18,7 +18,7 @@ indent_size = 4
indent_style = space
indent_size = 4

[{*.json,*.lsrules,*.yml,*.bowerrc,*.babelrc}]
[{*.json,*.lsrules,*.yaml,*.yml,*.bowerrc,*.babelrc,*.code-workspace}]
indent_style = space
indent_size = 2

Expand Down
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 2024 January 3
# https://github.com/bevry/base

# never modify any line ending in any file, disregarding all nonsense from eol, autocrlf, renormalize, safecrlf, usecrlfattr, allBinary
* -text

# =====================================
# CUSTOM
3 changes: 2 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ patreon: bevry
open_collective: bevry
ko_fi: balupton
liberapay: bevry
custom: ['https://bevry.me/fund']
tidelift: npm/watchr
custom: ['https://bevry.me/fund']
59 changes: 59 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 2023 November 13
# https://github.com/bevry/base

# VCS Files
.git
.svn
.hg

# System Files
**/.DS_Store

# Temp Files
**/.docpad.db
**/*.log
**/*.cpuprofile
**/*.heapsnapshot

# Yarn Files
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
.pnp/

# Build Caches
build/
components/
bower_components/
node_modules/

# Build Outputs
**/*.cjs
**/*.mjs
**/out.*
**/*.out.*
**/out/
**/output/
*compiled*
edition*/
coffeejs/
coffee/
es5/
es2015/
esnext/
docs/

# Development Files
test/
**/*fixtures*

# Ecosystem Caches
.trunk/*/

# =====================================
# CUSTOM

# None
15 changes: 15 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# History

## v7.0.0 2024 January 3

- This should be a backwards compatible release, as the public API has not changed, supporting graceful upgradation (specially around scanning directories and ignore customisation)
- Implemented in TypeScript
- Closes [issue #102](https://github.com/bevry/watchr/issues/102)
- Fixed change handling not operating in parallel
- Removed private methods that no longer needed: `getIgnoredOptions`
- Upgraded for [`scandirectory` v8](https://github.com/bevry/scandirectory) and [`ignorefs` v5](https://github.com/bevry/ignorefs) which no longer use [`readdir-cluster``](https://github.com/bevry/readdir-cluster)
- This offers improved performance, compatibility, and ignore customisation
- Closes [issue #341](https://github.com/bevry/watchr/issues/341)
- Closes [issue #92](https://github.com/bevry/watchr/issues/92), [issue #81](https://github.com/bevry/watchr/issues/81), [issue #44](https://github.com/bevry/watchr/issues/44)
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)
- Closes [issue #342](https://github.com/bevry/watchr/issues/342), [issue #98](https://github.com/bevry/watchr/issues/98)
- Thank you to the sponsors: [Andrew Nesbitt](https://nesbitt.io), [Balsa](https://balsa.com), [Codecov](https://codecov.io), [Frontend Masters](https://FrontendMasters.com), [Poonacha Medappa](https://poonachamedappa.com), [Rob Morris](https://github.com/Rob-Morris), [Sentry](https://sentry.io), [Syntax](https://syntax.fm)

## v6.11.0 2021 July 31

- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)
Expand Down
24 changes: 1 addition & 23 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,2 @@
<!-- LICENSEFILE/ -->

<h1>License</h1>

Unless stated otherwise all works are:

<ul><li>Copyright &copy; 2012+ <a href="http://bevry.me">Bevry Pty Ltd</a></li>
<li>Copyright &copy; 2011 <a href="https://balupton.com">Benjamin Lupton</a></li></ul>

and licensed under:

<ul><li><a href="http://spdx.org/licenses/MIT.html">MIT License</a></li></ul>

<h2>MIT License</h2>

<pre>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights 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 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.
</pre>

<!-- /LICENSEFILE -->
<!-- LICENSEFILE -->
59 changes: 32 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<!-- /TITLE -->


<!-- BADGES/ -->

<span class="badge-githubworkflow"><a href="https://github.com/bevry/watchr/actions?query=workflow%3Abevry" title="View the status of this project's GitHub Workflow: bevry"><img src="https://github.com/bevry/watchr/workflows/bevry/badge.svg" alt="Status of the GitHub Workflow: bevry" /></a></span>
Expand All @@ -25,13 +24,20 @@

<!-- /BADGES -->


Watchr provides a normalised API the file watching APIs of different node versions, nested/recursive file and directory watching, and accurate detailed events for file/directory creations, updates, and deletions.

## Usage

[Complete API Documentation.](http://master.watchr.bevry.surge.sh/docs/)









There are two concepts in watchr, they are:

- Watcher - this wraps the native file system watching, makes it reliable, and supports deep watching
Expand All @@ -41,10 +47,10 @@ The simplest usage is:

```javascript
// Import the watching library
var watchr = require('watchr')
import { open } from 'watchr'

// Define our watching parameters
var path = process.cwd()
const path = process.cwd()
function listener(changeType, fullPath, currentStat, previousStat) {
switch (changeType) {
case 'update':
Expand All @@ -70,7 +76,7 @@ function next(err) {
}

// Watch the path with the change listener and completion callback
var stalker = watchr.open(path, listener, next)
var stalker = open(path, listener, next)

// Close the stalker of the watcher
stalker.close()
Expand All @@ -79,43 +85,46 @@ stalker.close()
More advanced usage is:

```javascript
// Import the watching library
import { create } from 'watchr'

// Create the stalker for the path
var stalker = watchr.create(path)
const stalker = create(path)

// Listen to the events for the stalker/watcher
stalker.on('change', listener)
stalker.on('change', listener) // use the listener from earlier
stalker.on('log', console.log)
stalker.once('close', function (reason) {
console.log('closed', path, 'because', reason)
stalker.removeAllListeners() // as it is closed, no need for our change or log listeners any more
})

// Set the default configuration for the stalker/watcher
// Set custom configuration for the stalker/watcher
stalker.setConfig({
stat: null,
interval: 5007,
persistent: true,
catchupDelay: 2000,
preferredMethods: ['watch', 'watchFile'],
followLinks: true,
ignorePaths: false,
ignoreHiddenFiles: false,
ignoreCommonPatterns: true,
ignoreCustomPatterns: null,
// ...
})

// Start watching
stalker.watch(next)
stalker.watch(next) // use the next callback from earlier

// Stop watching
stalker.close()
```









<!-- INSTALL/ -->

<h2>Install</h2>

<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>npm</h3></a>

<ul>
<li>Install: <code>npm install --save watchr</code></li>
<li>Import: <code>import * as pkg from ('watchr')</code></li>
Expand All @@ -133,17 +142,16 @@ stalker.close()

This project provides its type information via inline <a href="http://usejsdoc.org" title="JSDoc is an API documentation generator for JavaScript, similar to Javadoc or phpDocumentor">JSDoc Comments</a>. To make use of this in <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a>, set your <code>maxNodeModuleJsDepth</code> compiler option to `5` or thereabouts. You can accomlish this via your `tsconfig.json` file like so:

``` json
```json
{
"compilerOptions": {
"maxNodeModuleJsDepth": 5
}
"compilerOptions": {
"maxNodeModuleJsDepth": 5
}
}
```

<!-- /INSTALL -->


<!-- HISTORY/ -->

<h2>History</h2>
Expand All @@ -152,7 +160,6 @@ This project provides its type information via inline <a href="http://usejsdoc.o

<!-- /HISTORY -->


<!-- CONTRIBUTE/ -->

<h2>Contribute</h2>
Expand All @@ -161,7 +168,6 @@ This project provides its type information via inline <a href="http://usejsdoc.o

<!-- /CONTRIBUTE -->


<!-- BACKERS/ -->

<h2>Backers</h2>
Expand Down Expand Up @@ -204,7 +210,6 @@ These amazing people have contributed code to this project:

<!-- /BACKERS -->


<!-- LICENSE/ -->

<h2>License</h2>
Expand Down
21 changes: 21 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Security Policy

## Security Practices

This project meets standardized secure software development practices, including 2FA for all members, password managers with monitoring, secure secret retrieval instead of storage. [Learn about our practices.](https://tidelift.com/funding/github/npm/watchr)

## Supported Versions

This project uses [Bevry's automated tooling](https://github.com/bevry/boundation) to deliver the latest updates, fixes, and improvements inside the latest release while still maintaining widespread ecosystem compatibility.

[Refer to supported ecosystem versions: `Editions` section in `README.md`](https://github.com/bevry/watchr/blob/master/README.md#Editions)

[Refer to automated support of ecosystem versions: `boundation` entries in `HISTORY.md`](https://github.com/bevry/watchr/blob/master/HISTORY.md)

Besides testing and verification, out CI also [auto-merges](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions) [Dependabot security updates](https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates) and [auto-publishes](https://github.com/bevry-actions/npm) successful builds of the [`master` branch](https://github.com/bevry/wait/actions?query=branch%3Amaster) to the [`next` version tag](https://www.npmjs.com/package/watchr?activeTab=versions), offering immediate resolutions before scheduled maintenance releases.

## Reporting a Vulnerability

[Report the vulnerability to the project owners.](https://github.com/bevry/watchr/security/advisories)

[Report the vulnerability to Tidelift.](https://tidelift.com/security)
4 changes: 4 additions & 0 deletions index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict'
// auto-generated by boundation, do not update manually
/** @type {typeof import("./edition-types/index.d.ts") } */
module.exports = require('editions').requirePackage(__dirname, require, 'index.js')
Loading

0 comments on commit 7fbe68c

Please sign in to comment.