Skip to content

Commit

Permalink
Upgrade to ts-dev-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
kmalakoff committed Feb 17, 2024
1 parent 8a92052 commit 8d1ac01
Show file tree
Hide file tree
Showing 99 changed files with 10,461 additions and 1,198 deletions.
2 changes: 1 addition & 1 deletion .depcheckrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ignores: ["depcheck"]
ignores: ["fs-iterator", "depcheck", "ts-dev-stack", "@types/*"]
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc.json

This file was deleted.

13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: daily
ignore:
- dependency-name: 'rimraf'
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
# Check for updates to GitHub Actions every weekday
interval: 'daily'
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI
on:
push:
branches:
- master
jobs:
test:
name: Node.js ${{ matrix.node-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['20']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: git config --global user.name "Github Actions"
- run: git config --global user.email "[email protected]"
- run: npm uninstall node-version-use -g
- run: npm install node-version-use -g
- run: npm ci
- run: npm run format
- run: npm run build
- run: npm run test:engines
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.DS_Store
.tmp/
node_modules/
package-lock.json
data/
*.heapsnapshot
*.0x
4 changes: 4 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"upgrade": true,
"reject": ["rimraf"]
}
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

11 changes: 10 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
{
"type": "node",
"request": "launch",
"name": "mocha",
"name": "test:node",
"program": "${workspaceFolder}/node_modules/mocha-compat/bin/_mocha-compat",
"args": ["--no-timeouts", "--colors", "${workspaceFolder}/test/spec/**/*.test.js"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "test:node",
"program": "${workspaceFolder}/node_modules/mocha-compat/bin/nvu",
"args": ["mocha-compat", "--no-timeouts", "--colors", "${workspaceFolder}/test/spec/**/*.test.js"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
Expand Down
34 changes: 34 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"files": {
"ignore": ["assets/**", "dist/**", "node_modules/**", "test/data/**"]
},
"formatter": {
"enabled": true,
"lineWidth": 320,
"indentStyle": "space"
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingComma": "es5"
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off",
"useOptionalChain": "off"
},
"correctness": {
"noUnusedVariables": "warn",
"noInnerDeclarations": "off"
},
"style": {
"noParameterAssign": "off"
}
}
}
}
8 changes: 8 additions & 0 deletions check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var Iterator = require('.')

var i = 0;

var iterator = new Iterator('/Users/kevin');
iterator.forEach((entry) => { if(i++%1000===0) console.log(entry.fullPath); }, { concurrency: Infinity }, function(err) {
console.log('DONE')
})
64 changes: 64 additions & 0 deletions dist/cjs/FSIterator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"use strict";
function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
var inherits = require("inherits");
var StackBaseIterator = require("stack-base-iterator");
var fs = require("fs");
var path = require("path");
var PathStack = require("./PathStack");
var fifoRemove = require("./fifoRemove");
var fsCompat = require("./fs-compat");
var lifoFromArray = require("./lifoFromArray");
function FSIterator(root, options) {
var _this = this;
if (!_instanceof(this, FSIterator)) return new FSIterator(root, options);
StackBaseIterator.call(this, options);
options = options || {};
if (this.options.depth === undefined) this.options.depth = Infinity;
this.options.readdir = {
encoding: "utf8",
withFileTypes: fs.Dirent && !options.alwaysStat
};
this.options.stat = {
bigint: process.platform === "win32"
};
this.options.error = options.error || function defaultError(err) {
return ~FSIterator.EXPECTED_ERRORS.indexOf(err.code); // skip known issues
};
this.root = path.resolve(root);
this.stack = new PathStack();
var cancelled = false;
function setup() {
cancelled = true;
}
this.processing.push(setup);
fsCompat.readdir(this.root, this.options.readdir, function(err, files) {
fifoRemove(_this.processing, setup);
if (_this.done || cancelled) return;
if (err) return _this.end(err);
if (files.length) _this.push({
path: null,
depth: 0,
files: lifoFromArray(files)
});
});
}
inherits(FSIterator, StackBaseIterator);
FSIterator.EXPECTED_ERRORS = [
"ENOENT",
"EPERM",
"EACCES",
"ELOOP"
];
module.exports = FSIterator;

if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
for (var key in exports) exports.default[key] = exports[key];
module.exports = exports.default;
}
1 change: 1 addition & 0 deletions dist/cjs/FSIterator.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions dist/cjs/PathStack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use strict";
var FIFO = require("fifo");
var depthFirst = require("./depthFirst");
function PathStack() {
this.stack = new FIFO();
this.length = 0;
}
PathStack.prototype.push = function push(item) {
if (!item) throw new Error("item is mandatory");
if (item.files && !item.files.length) throw new Error("item files must have a length");
this.stack.push(item);
this.length += item.files ? item.files.length : 1;
return this;
};
PathStack.prototype.pop = function pop() {
if (!this.stack.length) throw new Error("Stack is empty");
var item = this.stack.last();
this.length--;
// just a simple item
if (!item.files) return depthFirst.bind(null, this.stack.pop());
// resuse this item
if (item.files.length > 1) return depthFirst.bind(null, {
path: item.path,
basename: item.files.pop(),
depth: item.depth
});
// done with this item
item.basename = item.files.pop();
return depthFirst.bind(null, this.stack.pop());
};
PathStack.prototype.last = function last() {
return this.stack.last();
};
module.exports = PathStack;

if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
for (var key in exports) exports.default[key] = exports[key];
module.exports = exports.default;
}
1 change: 1 addition & 0 deletions dist/cjs/PathStack.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions dist/cjs/depthFirst/createEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";
var sep = require("path").sep;
function join(left, right) {
if (!left) return right || "";
if (!right) return left;
return left + sep + right;
}
module.exports = function createEntry(iterator, item) {
var entry = {};
if (item.basename.name) {
entry.basename = item.basename.name;
entry.stats = item.basename;
} else {
entry.basename = item.basename;
}
entry.path = join(item.path, entry.basename);
entry.fullPath = join(iterator.root, entry.path);
return entry;
};

if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
for (var key in exports) exports.default[key] = exports[key];
module.exports = exports.default;
}
1 change: 1 addition & 0 deletions dist/cjs/depthFirst/createEntry.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions dist/cjs/depthFirst/filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";
var compat = require("async-compat");
module.exports = function filter(iterator, entry, callback) {
if (!iterator.options.filter) return callback(null, true);
compat.asyncFunction(iterator.options.filter, iterator.options.callbacks, entry, function filterCallback(err, keep) {
if (err) return callback(err);
if (!compat.defaultValue(keep, true)) return callback();
callback(null, true);
});
};

if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
for (var key in exports) exports.default[key] = exports[key];
module.exports = exports.default;
}
1 change: 1 addition & 0 deletions dist/cjs/depthFirst/filter.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions dist/cjs/depthFirst/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use strict";
var createEntry = require("./createEntry");
var filter = require("./filter");
var stat = require("./stat");
var fsCompat = require("../fs-compat");
var lifoFromArray = require("../lifoFromArray");
function isDirectory(entry) {
if (entry.realStats) return entry.realStats.isDirectory();
return entry.stats.isDirectory();
}
module.exports = function path(item, iterator, callback) {
var depth = item.depth;
var entry = createEntry(iterator, item);
item = null; // release reference
stat(iterator, entry, function statCallback(err) {
if (err || iterator.done) return callback(err);
filter(iterator, entry, function filterCallback(err, keep) {
if (err || !keep || iterator.done) return callback(err);
// not a directory or is a directory, but next level is too deep
if (!isDirectory(entry) || depth + 1 > iterator.options.depth) return callback(null, entry);
// get files in this directory
fsCompat.readdir(entry.fullPath, iterator.options.readdir, function readdirCallback(err, files) {
if (err || iterator.done) return callback(err);
if (files.length) iterator.push({
path: entry.path,
depth: depth + 1,
files: lifoFromArray(files)
});
return callback(null, entry);
});
});
});
};

if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
for (var key in exports) exports.default[key] = exports[key];
module.exports = exports.default;
}
Loading

0 comments on commit 8d1ac01

Please sign in to comment.