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,31 @@
import * as assert from 'assert';
import * as fs from 'fs';
import { Stats } from '../../../fs.macchiato';
import * as adapter from './fs';
describe('Adapters → FileSystem', () => {
it('should return original FS methods', () => {
const expected: adapter.FileSystemAdapter = adapter.FILE_SYSTEM_ADAPTER;
const actual = adapter.createFileSystemAdapter();
assert.deepStrictEqual(actual, expected);
});
it('should return custom FS methods', () => {
const customLstatSyncMethod: typeof fs.lstatSync = () => new Stats();
const expected: adapter.FileSystemAdapter = {
...adapter.FILE_SYSTEM_ADAPTER,
lstatSync: customLstatSyncMethod
};
const actual = adapter.createFileSystemAdapter({
lstatSync: customLstatSyncMethod
});
assert.deepStrictEqual(actual, expected);
});
});

26
bulma/node_modules/@nodelib/fs.stat/src/adapters/fs.ts generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import * as fs from 'fs';
export type FileSystemAdapter = {
lstat: typeof fs.lstat;
stat: typeof fs.stat;
lstatSync: typeof fs.lstatSync;
statSync: typeof fs.statSync;
};
export const FILE_SYSTEM_ADAPTER: FileSystemAdapter = {
lstat: fs.lstat,
stat: fs.stat,
lstatSync: fs.lstatSync,
statSync: fs.statSync
};
export function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter {
if (fsMethods === undefined) {
return FILE_SYSTEM_ADAPTER;
}
return {
...FILE_SYSTEM_ADAPTER,
...fsMethods
};
}

70
bulma/node_modules/@nodelib/fs.stat/src/index.spec.ts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
import * as assert from 'assert';
import * as fs from 'fs';
import * as rimraf from 'rimraf';
import { stat, statSync, Settings } from '.';
describe('Package', () => {
before(() => {
rimraf.sync('fixtures');
fs.mkdirSync('fixtures');
fs.mkdirSync('fixtures/a');
fs.symlinkSync('a', 'fixtures/b', 'junction');
});
after(() => {
rimraf.sync('fixtures');
});
describe('.stat', () => {
it('should work without options or settings', (done) => {
stat('fixtures/b', (error, stats) => {
assert.strictEqual(error, null);
assert.ok(stats);
done();
});
});
it('should work with options', (done) => {
stat('fixtures/b', { markSymbolicLink: true }, (error, stats) => {
assert.strictEqual(error, null);
assert.strictEqual(stats.isSymbolicLink(), true);
done();
});
});
it('should work with settings', (done) => {
const settings = new Settings({ markSymbolicLink: true });
stat('fixtures/b', settings, (error, stats) => {
assert.strictEqual(error, null);
assert.strictEqual(stats.isSymbolicLink(), true);
done();
});
});
});
describe('.statSync', () => {
it('should work without options or settings', () => {
const actual = statSync('fixtures/b');
assert.ok(actual);
});
it('should work with options', () => {
const actual = statSync('fixtures/b', { markSymbolicLink: true });
assert.strictEqual(actual.isSymbolicLink(), true);
});
it('should work with settings', () => {
const settings = new Settings({ markSymbolicLink: true });
const actual = statSync('fixtures/b', settings);
assert.strictEqual(actual.isSymbolicLink(), true);
});
});
});

50
bulma/node_modules/@nodelib/fs.stat/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import { FileSystemAdapter } from './adapters/fs';
import * as async from './providers/async';
import * as sync from './providers/sync';
import Settings, { Options } from './settings';
import { Stats } from './types';
type AsyncCallback = async.AsyncCallback;
function stat(path: string, callback: AsyncCallback): void;
function stat(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
function stat(path: string, optionsOrSettingsOrCallback: Options | Settings | AsyncCallback, callback?: AsyncCallback): void {
if (typeof optionsOrSettingsOrCallback === 'function') {
return async.read(path, getSettings(), optionsOrSettingsOrCallback);
}
async.read(path, getSettings(optionsOrSettingsOrCallback), callback as AsyncCallback);
}
// https://github.com/typescript-eslint/typescript-eslint/issues/60
// eslint-disable-next-line no-redeclare
declare namespace stat {
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Stats>;
}
function statSync(path: string, optionsOrSettings?: Options | Settings): Stats {
const settings = getSettings(optionsOrSettings);
return sync.read(path, settings);
}
function getSettings(settingsOrOptions: Settings | Options = {}): Settings {
if (settingsOrOptions instanceof Settings) {
return settingsOrOptions;
}
return new Settings(settingsOrOptions);
}
export {
Settings,
stat,
statSync,
// https://github.com/typescript-eslint/typescript-eslint/issues/131
// eslint-disable-next-line no-undef
AsyncCallback,
FileSystemAdapter,
Options,
Stats
};

View File

@@ -0,0 +1,102 @@
import * as assert from 'assert';
import * as fs from 'fs';
import * as sinon from 'sinon';
import { Stats } from '../../../fs.macchiato';
import Settings from '../settings';
import * as provider from './async';
describe('Providers → Async', () => {
describe('.read', () => {
it('should return lstat for non-symlink entry', (done) => {
const lstat = sinon.stub().yields(null, new Stats()) as unknown as typeof fs.lstat;
const settings = new Settings({
fs: { lstat }
});
provider.read('filepath', settings, (error, stats) => {
assert.strictEqual(error, null);
assert.strictEqual(stats.ino, 0);
done();
});
});
it('should return lstat for symlink entry when the "followSymbolicLink" option is disabled', (done) => {
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
const settings = new Settings({
followSymbolicLink: false,
fs: { lstat }
});
provider.read('filepath', settings, (error, stats) => {
assert.strictEqual(error, null);
assert.strictEqual(stats.ino, 0);
done();
});
});
it('should return stat for symlink entry', (done) => {
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
const stat = sinon.stub().yields(null, new Stats({ ino: 1 })) as unknown as typeof fs.stat;
const settings = new Settings({
fs: { lstat, stat }
});
provider.read('filepath', settings, (error, stats) => {
assert.strictEqual(error, null);
assert.strictEqual(stats.ino, 1);
done();
});
});
it('should return marked stat for symlink entry when the "markSymbolicLink" option is enabled', (done) => {
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
const stat = sinon.stub().yields(null, new Stats({ ino: 1 })) as unknown as typeof fs.stat;
const settings = new Settings({
fs: { lstat, stat },
markSymbolicLink: true
});
provider.read('filepath', settings, (error, stats) => {
assert.strictEqual(error, null);
assert.strictEqual(stats.isSymbolicLink(), true);
done();
});
});
it('should return lstat for broken symlink entry when the "throwErrorOnBrokenSymbolicLink" option is disabled', (done) => {
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
const stat = sinon.stub().yields(new Error()) as unknown as typeof fs.stat;
const settings = new Settings({
fs: { lstat, stat },
throwErrorOnBrokenSymbolicLink: false
});
provider.read('filepath', settings, (error, stats) => {
assert.strictEqual(error, null);
assert.strictEqual(stats.ino, 0);
done();
});
});
it('should throw an error when symlink entry is broken', (done) => {
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
const stat = sinon.stub().yields(new Error('broken')) as unknown as typeof fs.stat;
const settings = new Settings({
fs: { lstat, stat }
});
provider.read('filepath', settings, (error) => {
assert.strictEqual(error.message, 'broken');
done();
});
});
});
});

View File

@@ -0,0 +1,43 @@
import Settings from '../settings';
import { ErrnoException, Stats } from '../types';
type FailureCallback = (err: ErrnoException) => void;
type SuccessCallback = (err: null, stats: Stats) => void;
export type AsyncCallback = (err: ErrnoException, stats: Stats) => void;
export function read(path: string, settings: Settings, callback: AsyncCallback): void {
settings.fs.lstat(path, (lstatError, lstat) => {
if (lstatError !== null) {
return callFailureCallback(callback, lstatError);
}
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
return callSuccessCallback(callback, lstat);
}
settings.fs.stat(path, (statError, stat) => {
if (statError !== null) {
if (settings.throwErrorOnBrokenSymbolicLink) {
return callFailureCallback(callback, statError);
}
return callSuccessCallback(callback, lstat);
}
if (settings.markSymbolicLink) {
stat.isSymbolicLink = () => true;
}
callSuccessCallback(callback, stat);
});
});
}
function callFailureCallback(callback: AsyncCallback, error: ErrnoException): void {
(callback as FailureCallback)(error);
}
function callSuccessCallback(callback: AsyncCallback, result: Stats): void {
(callback as unknown as SuccessCallback)(null, result);
}

View File

@@ -0,0 +1,90 @@
import * as assert from 'assert';
import * as sinon from 'sinon';
import { Stats } from '../../../fs.macchiato';
import Settings from '../settings';
import * as provider from './sync';
describe('Providers → Sync', () => {
describe('.read', () => {
it('should return lstat for non-symlink entry', () => {
const lstatSync = sinon.stub().returns(new Stats());
const settings = new Settings({
fs: { lstatSync }
});
const actual = provider.read('filepath', settings);
assert.strictEqual(actual.ino, 0);
});
it('should return lstat for symlink entry when the "followSymbolicLink" option is disabled', () => {
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
const settings = new Settings({
followSymbolicLink: false,
fs: { lstatSync }
});
const actual = provider.read('filepath', settings);
assert.strictEqual(actual.ino, 0);
});
it('should return stat for symlink entry', () => {
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
const statSync = sinon.stub().returns(new Stats({ ino: 1 }));
const settings = new Settings({
fs: { lstatSync, statSync }
});
const actual = provider.read('filepath', settings);
assert.strictEqual(actual.ino, 1);
});
it('should return marked stat for symlink entry when the "markSymbolicLink" option is enabled', () => {
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
const statSync = sinon.stub().returns(new Stats({ ino: 1 }));
const settings = new Settings({
markSymbolicLink: true,
fs: { lstatSync, statSync }
});
const actual = provider.read('filepath', settings);
assert.strictEqual(actual.isSymbolicLink(), true);
});
it('should return lstat for broken symlink entry when the "throwErrorOnBrokenSymbolicLink" option is disabled', () => {
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
const statSync = sinon.stub().throws(new Error('error'));
const settings = new Settings({
fs: { lstatSync, statSync },
throwErrorOnBrokenSymbolicLink: false
});
const actual = provider.read('filepath', settings);
assert.strictEqual(actual.ino, 0);
});
it('should throw an error when symlink entry is broken', () => {
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
const statSync = sinon.stub().throws(new Error('broken'));
const settings = new Settings({
fs: { lstatSync, statSync }
});
const expectedErrorMessageRe = /broken/;
assert.throws(() => provider.read('filepath', settings), expectedErrorMessageRe);
});
});
});

View File

@@ -0,0 +1,26 @@
import Settings from '../settings';
import { Stats } from '../types';
export function read(path: string, settings: Settings): Stats {
const lstat = settings.fs.lstatSync(path);
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
return lstat;
}
try {
const stat = settings.fs.statSync(path);
if (settings.markSymbolicLink) {
stat.isSymbolicLink = () => true;
}
return stat;
} catch (error) {
if (!settings.throwErrorOnBrokenSymbolicLink) {
return lstat;
}
throw error;
}
}

View File

@@ -0,0 +1,31 @@
import * as assert from 'assert';
import { Stats } from '../../fs.macchiato';
import * as fs from './adapters/fs';
import Settings from './settings';
describe('Settings', () => {
it('should return instance with default values', () => {
const settings = new Settings();
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter());
assert.ok(settings.throwErrorOnBrokenSymbolicLink);
assert.ok(!settings.markSymbolicLink);
assert.ok(settings.followSymbolicLink);
});
it('should return instance with custom values', () => {
const lstatSync = (): Stats => new Stats();
const settings = new Settings({
followSymbolicLink: false,
fs: fs.createFileSystemAdapter({ lstatSync }),
throwErrorOnBrokenSymbolicLink: false
});
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter({ lstatSync }));
assert.ok(!settings.throwErrorOnBrokenSymbolicLink);
assert.ok(!settings.followSymbolicLink);
});
});

21
bulma/node_modules/@nodelib/fs.stat/src/settings.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import * as fs from './adapters/fs';
export type Options = {
followSymbolicLink?: boolean;
fs?: Partial<fs.FileSystemAdapter>;
markSymbolicLink?: boolean;
throwErrorOnBrokenSymbolicLink?: boolean;
};
export default class Settings {
public readonly followSymbolicLink: boolean = this._getValue(this._options.followSymbolicLink, true);
public readonly fs: fs.FileSystemAdapter = fs.createFileSystemAdapter(this._options.fs);
public readonly markSymbolicLink: boolean = this._getValue(this._options.markSymbolicLink, false);
public readonly throwErrorOnBrokenSymbolicLink: boolean = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
constructor(private readonly _options: Options = {}) { }
private _getValue<T>(option: T | undefined, value: T): T {
return option ?? value;
}
}

View File

@@ -0,0 +1,4 @@
import * as fs from 'fs';
export type Stats = fs.Stats;
export type ErrnoException = NodeJS.ErrnoException;