Remove unnecessary resources, add bulma, and add AdvMakefile

This commit is contained in:
2021-03-29 15:02:41 -07:00
parent 69f2d46a8c
commit bb2c9351d6
6084 changed files with 674187 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
import Settings from '../settings';
import { Entry } from '../types';
export declare type AsyncCallback = (err: NodeJS.ErrnoException, entries: Entry[]) => void;
export declare function read(directory: string, settings: Settings, callback: AsyncCallback): void;
export declare function readdirWithFileTypes(directory: string, settings: Settings, callback: AsyncCallback): void;
export declare function readdir(directory: string, settings: Settings, callback: AsyncCallback): void;
//# sourceMappingURL=async.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/providers/async.ts"],"names":[],"mappings":";AAIA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAS,MAAM,UAAU,CAAC;AASxC,oBAAY,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;AAEnF,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAMzF;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CA0BzG;AAwBD,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAsC5F"}

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
const fsStat = require("@nodelib/fs.stat");
const rpl = require("run-parallel");
const constants_1 = require("../constants");
const utils = require("../utils");
const common = require("./common");
function read(directory, settings, callback) {
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
return readdirWithFileTypes(directory, settings, callback);
}
return readdir(directory, settings, callback);
}
exports.read = read;
function readdirWithFileTypes(directory, settings, callback) {
settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => {
if (readdirError !== null) {
return callFailureCallback(callback, readdirError);
}
const entries = dirents.map((dirent) => ({
dirent,
name: dirent.name,
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
}));
if (!settings.followSymbolicLinks) {
return callSuccessCallback(callback, entries);
}
const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings));
rpl(tasks, (rplError, rplEntries) => {
if (rplError !== null) {
return callFailureCallback(callback, rplError);
}
callSuccessCallback(callback, rplEntries);
});
});
}
exports.readdirWithFileTypes = readdirWithFileTypes;
function makeRplTaskEntry(entry, settings) {
return (done) => {
if (!entry.dirent.isSymbolicLink()) {
return done(null, entry);
}
settings.fs.stat(entry.path, (statError, stats) => {
if (statError !== null) {
if (settings.throwErrorOnBrokenSymbolicLink) {
return done(statError);
}
return done(null, entry);
}
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
return done(null, entry);
});
};
}
function readdir(directory, settings, callback) {
settings.fs.readdir(directory, (readdirError, names) => {
if (readdirError !== null) {
return callFailureCallback(callback, readdirError);
}
const filepaths = names.map((name) => common.joinPathSegments(directory, name, settings.pathSegmentSeparator));
const tasks = filepaths.map((filepath) => {
return (done) => fsStat.stat(filepath, settings.fsStatSettings, done);
});
rpl(tasks, (rplError, results) => {
if (rplError !== null) {
return callFailureCallback(callback, rplError);
}
const entries = [];
names.forEach((name, index) => {
const stats = results[index];
const entry = {
name,
path: filepaths[index],
dirent: utils.fs.createDirentFromStats(name, stats)
};
if (settings.stats) {
entry.stats = stats;
}
entries.push(entry);
});
callSuccessCallback(callback, entries);
});
});
}
exports.readdir = readdir;
function callFailureCallback(callback, error) {
callback(error);
}
function callSuccessCallback(callback, result) {
callback(null, result);
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=async.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.spec.d.ts","sourceRoot":"","sources":["../../src/providers/async.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,180 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const sinon = require("sinon");
const fs_macchiato_1 = require("../../../fs.macchiato");
const constants_1 = require("../constants");
const settings_1 = require("../settings");
const provider = require("./async");
const ROOT_PATH = 'root';
const FIRST_FILE_PATH = 'first.txt';
const SECOND_FILE_PATH = 'second.txt';
const FIRST_ENTRY_PATH = path.join(ROOT_PATH, FIRST_FILE_PATH);
const SECOND_ENTRY_PATH = path.join(ROOT_PATH, SECOND_FILE_PATH);
describe('Providers → Async', () => {
describe('.read', () => {
it('should call correct method based on Node.js version', (done) => {
const readdir = sinon.stub();
readdir.yields(null, []);
const settings = new settings_1.default({
fs: { readdir: readdir }
});
provider.read(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries, []);
if (constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
sinon.assert.match(readdir.args, [[ROOT_PATH, { withFileTypes: true }, sinon.match.func]]);
}
else {
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
}
done();
});
});
it('should always use `readdir` method when the `stats` option is enabled', (done) => {
const readdir = sinon.stub();
readdir.yields(null, []);
const settings = new settings_1.default({
fs: { readdir: readdir },
stats: true
});
provider.read(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries, []);
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
done();
});
});
});
describe('.readdirWithFileTypes', () => {
it('should return entries', (done) => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const readdir = sinon.stub();
readdir.yields(null, [dirent]);
const settings = new settings_1.default({
fs: { readdir: readdir }
});
const expected = [
{
dirent,
name: FIRST_FILE_PATH,
path: FIRST_ENTRY_PATH
}
];
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
sinon.assert.match(readdir.args, [[ROOT_PATH, { withFileTypes: true }, sinon.match.func]]);
assert.deepStrictEqual(entries, expected);
done();
});
});
it('should call fs.stat for symbolic link when the "followSymbolicLink" option is enabled', (done) => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const secondDirent = new fs_macchiato_1.Dirent({ name: SECOND_FILE_PATH, isSymbolicLink: true });
const stats = new fs_macchiato_1.Stats();
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent, secondDirent]);
stat.yields(null, stats);
const settings = new settings_1.default({
followSymbolicLinks: true,
fs: {
readdir: readdir,
stat: stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 2);
assert.ok(!entries[1].dirent.isSymbolicLink());
sinon.assert.match(stat.args, [[SECOND_ENTRY_PATH, sinon.match.func]]);
done();
});
});
it('should return lstat for broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is disabled', (done) => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent]);
stat.yields(new Error('error'));
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: false,
fs: {
readdir: readdir,
stat: stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 1);
assert.ok(entries[0].dirent.isSymbolicLink());
done();
});
});
it('should throw an error fro broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is enabled', (done) => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent]);
stat.yields(new Error('error'));
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: true,
fs: {
readdir: readdir,
stat: stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error.message, 'error');
assert.strictEqual(entries, undefined);
done();
});
});
});
describe('.readdir', () => {
it('should return entries', (done) => {
const stats = new fs_macchiato_1.Stats();
const readdir = sinon.stub();
const lstat = sinon.stub();
readdir.yields(null, [FIRST_FILE_PATH]);
lstat.yields(null, stats);
const settings = new settings_1.default({
fs: {
readdir: readdir,
lstat: lstat
}
});
provider.readdir(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
sinon.assert.match(lstat.args, [[FIRST_ENTRY_PATH, sinon.match.func]]);
assert.strictEqual(entries[0].name, FIRST_FILE_PATH);
assert.strictEqual(entries[0].path, FIRST_ENTRY_PATH);
assert.strictEqual(entries[0].dirent.name, FIRST_FILE_PATH);
done();
});
});
it('should return entries with `stats` property', (done) => {
const stats = new fs_macchiato_1.Stats();
const readdir = sinon.stub();
const lstat = sinon.stub();
readdir.yields(null, [FIRST_FILE_PATH]);
lstat.yields(null, stats);
const settings = new settings_1.default({
fs: {
readdir: readdir,
lstat: lstat
},
stats: true
});
provider.readdir(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries[0].stats, stats);
done();
});
});
});
});

View File

@@ -0,0 +1,2 @@
export declare function joinPathSegments(a: string, b: string, separator: string): string;
//# sourceMappingURL=common.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/providers/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAShF"}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.joinPathSegments = void 0;
function joinPathSegments(a, b, separator) {
/**
* The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
*/
if (a.endsWith(separator)) {
return a + b;
}
return a + separator + b;
}
exports.joinPathSegments = joinPathSegments;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=common.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.spec.d.ts","sourceRoot":"","sources":["../../src/providers/common.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const common = require("./common");
describe('Readers → Common', () => {
describe('.joinPathSegments', () => {
it('should return concatenated string', () => {
assert.strictEqual(common.joinPathSegments('.', 'a', '/'), './a');
});
it('should return correct string when the first segment ens with the separator symbol', () => {
// Unix
assert.strictEqual(common.joinPathSegments('/', 'a', '/'), '/a');
assert.strictEqual(common.joinPathSegments('//', 'a', '/'), '//a');
assert.strictEqual(common.joinPathSegments('/a/', 'b', '/'), '/a/b');
// Windows
assert.strictEqual(common.joinPathSegments('C:/', 'Users', '/'), 'C:/Users');
assert.strictEqual(common.joinPathSegments('C:\\', 'Users', '\\'), 'C:\\Users');
assert.strictEqual(common.joinPathSegments('//?/C:/', 'Users', '/'), '//?/C:/Users');
assert.strictEqual(common.joinPathSegments('\\\\?\\C:\\', 'Users', '\\'), '\\\\?\\C:\\Users');
});
});
});

View File

@@ -0,0 +1,6 @@
import Settings from '../settings';
import { Entry } from '../types';
export declare function read(directory: string, settings: Settings): Entry[];
export declare function readdirWithFileTypes(directory: string, settings: Settings): Entry[];
export declare function readdir(directory: string, settings: Settings): Entry[];
//# sourceMappingURL=sync.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/providers/sync.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAMnE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAwBnF;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAmBtE"}

View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
const fsStat = require("@nodelib/fs.stat");
const constants_1 = require("../constants");
const utils = require("../utils");
const common = require("./common");
function read(directory, settings) {
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
return readdirWithFileTypes(directory, settings);
}
return readdir(directory, settings);
}
exports.read = read;
function readdirWithFileTypes(directory, settings) {
const dirents = settings.fs.readdirSync(directory, { withFileTypes: true });
return dirents.map((dirent) => {
const entry = {
dirent,
name: dirent.name,
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
};
if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
try {
const stats = settings.fs.statSync(entry.path);
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
}
catch (error) {
if (settings.throwErrorOnBrokenSymbolicLink) {
throw error;
}
}
}
return entry;
});
}
exports.readdirWithFileTypes = readdirWithFileTypes;
function readdir(directory, settings) {
const names = settings.fs.readdirSync(directory);
return names.map((name) => {
const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
const stats = fsStat.statSync(entryPath, settings.fsStatSettings);
const entry = {
name,
path: entryPath,
dirent: utils.fs.createDirentFromStats(name, stats)
};
if (settings.stats) {
entry.stats = stats;
}
return entry;
});
}
exports.readdir = readdir;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=sync.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sync.spec.d.ts","sourceRoot":"","sources":["../../src/providers/sync.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,144 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const sinon = require("sinon");
const fs_macchiato_1 = require("../../../fs.macchiato");
const constants_1 = require("../constants");
const settings_1 = require("../settings");
const provider = require("./sync");
const ROOT_PATH = 'root';
const FIRST_FILE_PATH = 'first.txt';
const SECOND_FILE_PATH = 'second.txt';
const FIRST_ENTRY_PATH = path.join(ROOT_PATH, FIRST_FILE_PATH);
const SECOND_ENTRY_PATH = path.join(ROOT_PATH, SECOND_FILE_PATH);
describe('Providers → Sync', () => {
describe('.read', () => {
it('should call correct method based on Node.js version', () => {
const readdirSync = sinon.stub().returns([]);
const settings = new settings_1.default({
fs: { readdirSync: readdirSync }
});
const actual = provider.read(ROOT_PATH, settings);
assert.deepStrictEqual(actual, []);
if (constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH, { withFileTypes: true }]]);
}
else {
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
}
});
it('should always use `readdir` method when the `stats` option is enabled', () => {
const readdirSync = sinon.stub().returns([]);
const settings = new settings_1.default({
fs: { readdirSync: readdirSync },
stats: true
});
provider.read(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
});
});
describe('.readdirWithFileTypes', () => {
it('should return entries', () => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const readdirSync = sinon.stub().returns([dirent]);
const settings = new settings_1.default({
fs: { readdirSync: readdirSync }
});
const expected = [
{
dirent,
name: FIRST_FILE_PATH,
path: FIRST_ENTRY_PATH
}
];
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH, { withFileTypes: true }]]);
assert.deepStrictEqual(actual, expected);
});
it('should call fs.stat for symbolic link when the "followSymbolicLink" option is enabled', () => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const secondDirent = new fs_macchiato_1.Dirent({ name: SECOND_FILE_PATH, isSymbolicLink: true });
const stats = new fs_macchiato_1.Stats();
const readdirSync = sinon.stub().returns([firstDirent, secondDirent]);
const statSync = sinon.stub().returns(stats);
const settings = new settings_1.default({
followSymbolicLinks: true,
fs: {
readdirSync: readdirSync,
statSync: statSync
}
});
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.strictEqual(actual.length, 2);
assert.deepStrictEqual(statSync.args, [[SECOND_ENTRY_PATH]]);
assert.ok(!actual[1].dirent.isSymbolicLink());
});
it('should return lstat for broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is disabled', () => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdirSync = sinon.stub().returns([dirent]);
const statSync = () => {
throw new Error('error');
};
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: false,
fs: {
readdirSync: readdirSync,
statSync: statSync
}
});
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.strictEqual(actual.length, 1);
});
it('should throw an error fro broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is enabled', () => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdirSync = sinon.stub().returns([dirent]);
const statSync = () => {
throw new Error('error');
};
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: true,
fs: {
readdirSync: readdirSync,
statSync: statSync
}
});
const expectedErrorMessageRe = /Error: error/;
assert.throws(() => provider.readdirWithFileTypes(ROOT_PATH, settings), expectedErrorMessageRe);
});
});
describe('.readdir', () => {
it('should return entries', () => {
const stats = new fs_macchiato_1.Stats();
const readdirSync = sinon.stub().returns([FIRST_FILE_PATH]);
const lstatSync = sinon.stub().returns(stats);
const settings = new settings_1.default({
fs: {
readdirSync: readdirSync,
lstatSync: lstatSync
}
});
const actual = provider.readdir(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
assert.strictEqual(actual[0].name, FIRST_FILE_PATH);
assert.strictEqual(actual[0].path, FIRST_ENTRY_PATH);
assert.strictEqual(actual[0].dirent.name, FIRST_FILE_PATH);
});
it('should return entries with `stats` property', () => {
const stats = new fs_macchiato_1.Stats();
const readdirSync = sinon.stub().returns([FIRST_FILE_PATH]);
const lstatSync = sinon.stub().returns(stats);
const settings = new settings_1.default({
fs: {
readdirSync: readdirSync,
lstatSync: lstatSync
},
stats: true
});
const actual = provider.readdir(ROOT_PATH, settings);
assert.deepStrictEqual(actual[0].stats, stats);
});
});
});