jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.06k stars 216 forks source link

BFS is failing to build for various reasons #343

Closed DustinBrett closed 1 year ago

DustinBrett commented 1 year ago

Now when I run yarn upgrade on BFS it is causing build errors. I see some of them are related to things from my PR merging, but not all. Some such as Cred issues are from the latest PR by @james-pre. I'm not sure if this is because of other PR's being merged not liking what my PR had or what, because locally my PR was building, but now not.

> browserfs@2.0.0 dist
> npm-run-all build lint script:make_dist dist:build:node

> browserfs@2.0.0 build
> npm-run-all --parallel build:tsc build:scripts --sequential build:rollup --parallel build:webpack build:webpack-release

> browserfs@2.0.0 build:tsc
> tsc -p src

> browserfs@2.0.0 build:scripts
> tsc -p scripts

src/backend/FileSystemAccess.ts:59:55 - error TS2344: Type 'FileSystemAccessFileSystem' does not satisfy the constraint 'FileSystem'.
  Types of property 'rename' are incompatible.
    Type '(oldPath: string, newPath: string, cb: BFSOneArgCallback) => void' is not assignable to type '(oldPath: string, newPath: string, cred: Cred, cb: BFSOneArgCallback) => void'.
      Types of parameters 'cb' and 'cred' are incompatible.
        Type 'Cred' is not assignable to type 'BFSOneArgCallback'.
          Type 'Cred' provides no match for the signature '(e?: ApiError | null | undefined): any'.

59 export class FileSystemAccessFile extends PreloadFile<FileSystemAccessFileSystem> implements File {
                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~

src/backend/FileSystemAccess.ts:137:10 - error TS2416: Property 'rename' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(oldPath: string, newPath: string, cb: BFSOneArgCallback) => void' is not assignable to type '(oldPath: string, newPath: string, cred: Cred, cb: BFSOneArgCallback) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSOneArgCallback'.

137   public rename(oldPath: string, newPath: string, cb: BFSOneArgCallback): void {
             ~~~~~~

src/backend/FileSystemAccess.ts:137:10 - error TS2416: Property 'rename' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'FileSystem'.
  Type '(oldPath: string, newPath: string, cb: BFSOneArgCallback) => void' is not assignable to type '(oldPath: string, newPath: string, cred: Cred, cb: BFSOneArgCallback) => void'.

137   public rename(oldPath: string, newPath: string, cb: BFSOneArgCallback): void {
             ~~~~~~

src/backend/FileSystemAccess.ts:194:10 - error TS2416: Property 'writeFile' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number, cb: BFSCallback<File | undefined>, createFile?: boolean | undefined) => void' is not assignable to type '(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number, cred: Cred, cb: BFSOneArgCallback) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<File | undefined>'.
        Type 'Cred' provides no match for the signature '(e: ApiError | null | undefined, rv?: File | undefined): any'.

194   public writeFile(
             ~~~~~~~~~

src/backend/FileSystemAccess.ts:194:10 - error TS2416: Property 'writeFile' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'FileSystem'.
  Type '(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number, cb: BFSCallback<File | undefined>, createFile?: boolean | undefined) => void' is not assignable to type '(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number, cred: Cred, cb: BFSOneArgCallback) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<File | undefined>'.

194   public writeFile(
             ~~~~~~~~~

src/backend/FileSystemAccess.ts:229:10 - error TS2416: Property 'createFile' in type 'FileSystemAccessFileSystem' is not assignable 
to the same property in base type 'BaseFileSystem'.
  Type '(p: string, flag: FileFlag, mode: number, cb: BFSCallback<File>) => void' is not assignable to type '(p: string, flag: FileFlag, mode: number, cred: Cred, cb: BFSCallback<File>) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<File>'.
        Type 'Cred' provides no match for the signature '(e: ApiError | null | undefined, rv?: File | undefined): any'.

229   public createFile(p: string, flag: FileFlag, mode: number, cb: BFSCallback<File>): void {
             ~~~~~~~~~~

src/backend/FileSystemAccess.ts:233:10 - error TS2416: Property 'stat' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(path: string, isLstat: boolean, cb: BFSCallback<Stats>) => void' is not assignable to type '(p: string, isLstat: boolean | 
null, cred: Cred, cb: BFSCallback<Stats>) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<Stats>'.
        Type 'Cred' provides no match for the signature '(e: ApiError | null | undefined, rv?: Stats | undefined): any'.

233   public stat(path: string, isLstat: boolean, cb: BFSCallback<Stats>): void {
             ~~~~

src/backend/FileSystemAccess.ts:233:10 - error TS2416: Property 'stat' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'FileSystem'.
  Type '(path: string, isLstat: boolean, cb: BFSCallback<Stats>) => void' is not assignable to type '(p: string, isLstat: boolean | 
null, cred: Cred, cb: BFSCallback<Stats>) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<Stats>'.

233   public stat(path: string, isLstat: boolean, cb: BFSCallback<Stats>): void {
             ~~~~

src/backend/FileSystemAccess.ts:256:10 - error TS2416: Property 'exists' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(p: string, cb: (exists: boolean) => void) => void' is not assignable to type '(p: string, cred: Cred, cb: (exists: boolean) => void) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type '(exists: boolean) => void'.
        Type 'Cred' provides no match for the signature '(exists: boolean): void'.

256   public exists(p: string, cb: (exists: boolean) => void): void {
             ~~~~~~

src/backend/FileSystemAccess.ts:256:10 - error TS2416: Property 'exists' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'FileSystem'.
  Type '(p: string, cb: (exists: boolean) => void) => void' is not assignable to type '(p: string, cred: Cred, cb: (exists: boolean) => void) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type '(exists: boolean) => void'.

256   public exists(p: string, cb: (exists: boolean) => void): void {
             ~~~~~~

src/backend/FileSystemAccess.ts:260:10 - error TS2416: Property 'openFile' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(path: string, flags: FileFlag, cb: BFSCallback<File>) => void' is not assignable to type '(p: string, flag: FileFlag, cred: Cred, cb: BFSCallback<File>) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<File>'.

260   public openFile(path: string, flags: FileFlag, cb: BFSCallback<File>): void {
             ~~~~~~~~

src/backend/FileSystemAccess.ts:282:10 - error TS2416: Property 'unlink' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(path: string, cb: BFSOneArgCallback) => void' is not assignable to type '(p: string, cred: Cred, cb: BFSOneArgCallback) => 
void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSOneArgCallback'.

282   public unlink(path: string, cb: BFSOneArgCallback): void {
             ~~~~~~

src/backend/FileSystemAccess.ts:282:10 - error TS2416: Property 'unlink' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'FileSystem'.
  Type '(path: string, cb: BFSOneArgCallback) => void' is not assignable to type '(p: string, cred: Cred, cb: BFSOneArgCallback) => 
void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSOneArgCallback'.

282   public unlink(path: string, cb: BFSOneArgCallback): void {
             ~~~~~~

src/backend/FileSystemAccess.ts:294:10 - error TS2416: Property 'rmdir' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(path: string, cb: BFSOneArgCallback) => void' is not assignable to type '(p: string, cred: Cred, cb: BFSOneArgCallback) => 
void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSOneArgCallback'.

294   public rmdir(path: string, cb: BFSOneArgCallback): void {
             ~~~~~

src/backend/FileSystemAccess.ts:294:10 - error TS2416: Property 'rmdir' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'FileSystem'.
  Type '(path: string, cb: BFSOneArgCallback) => void' is not assignable to type '(p: string, cred: Cred, cb: BFSOneArgCallback) => 
void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSOneArgCallback'.

294   public rmdir(path: string, cb: BFSOneArgCallback): void {
             ~~~~~

src/backend/FileSystemAccess.ts:298:10 - error TS2416: Property 'mkdir' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'BaseFileSystem'.
  Type '(p: string, mode: any, cb: BFSOneArgCallback) => void' is not assignable to type '(p: string, mode: number, cred: Cred, cb: 
BFSOneArgCallback) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSOneArgCallback'.

298   public mkdir(p: string, mode: any, cb: BFSOneArgCallback): void {
             ~~~~~

src/backend/FileSystemAccess.ts:298:10 - error TS2416: Property 'mkdir' in type 'FileSystemAccessFileSystem' is not assignable to the same property in base type 'FileSystem'.
  Type '(p: string, mode: any, cb: BFSOneArgCallback) => void' is not assignable to type '(p: string, mode: number, cred: Cred, cb: 
BFSOneArgCallback) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSOneArgCallback'.

298   public mkdir(p: string, mode: any, cb: BFSOneArgCallback): void {
             ~~~~~

src/backend/FileSystemAccess.ts:317:10 - error TS2416: Property 'readdir' in type 'FileSystemAccessFileSystem' is not assignable to 
the same property in base type 'BaseFileSystem'.
  Type '(path: string, cb: BFSCallback<string[]>) => void' is not assignable to type '(p: string, cred: Cred, cb: BFSCallback<string[]>) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<string[]>'.
        Type 'Cred' provides no match for the signature '(e: ApiError | null | undefined, rv?: string[] | undefined): any'.

317   public readdir(path: string, cb: BFSCallback<string[]>): void {
             ~~~~~~~

src/backend/FileSystemAccess.ts:317:10 - error TS2416: Property 'readdir' in type 'FileSystemAccessFileSystem' is not assignable to 
the same property in base type 'FileSystem'.
  Type '(path: string, cb: BFSCallback<string[]>) => void' is not assignable to type '(p: string, cred: Cred, cb: BFSCallback<string[]>) => void'.
    Types of parameters 'cb' and 'cred' are incompatible.
      Type 'Cred' is not assignable to type 'BFSCallback<string[]>'.

317   public readdir(path: string, cb: BFSCallback<string[]>): void {
             ~~~~~~~

src/backend/HTTPRequest.ts:297:13 - error TS6133: 'stats' is declared but its value is never read.

297       const stats = inode.getData();
                ~~~~~

src/backend/HTTPRequest.ts:346:13 - error TS6133: 'stats' is declared but its value is never read.

346       const stats = inode.getData();
                ~~~~~

src/core/backends.ts:21:190 - error TS2345: Argument of type '(fsType: FileSystemConstructor) => void' is not assignable to parameter of type '(value: typeof AsyncMirror | typeof DropboxFileSystem | typeof EmscriptenFileSystem | typeof FileSystemAccessFileSystem | typeof FolderAdapter | typeof HTML5FS | typeof InMemoryFileSystem | typeof IndexedDBFileSystem | typeof LocalStorageFileSystem | ... 5 more ... | typeof IsoFS, index: number, array: (typeof Async...'.
  Types of parameters 'fsType' and 'value' are incompatible.
    Type 'typeof AsyncMirror | typeof DropboxFileSystem | typeof EmscriptenFileSystem | typeof FileSystemAccessFileSystem | typeof FolderAdapter | typeof HTML5FS | typeof InMemoryFileSystem | typeof IndexedDBFileSystem | typeof LocalStorageFileSystem | ... 5 more 
... | typeof IsoFS' is not assignable to type 'FileSystemConstructor'.
      Property 'CreateAsync' is missing in type 'typeof FileSystemAccessFileSystem' but required in type 'FileSystemConstructor'.   

21 [AsyncMirror, Dropbox, Emscripten, FileSystemAccess, FolderAdapter, HTML5FS, InMemory, IndexedDB, IsoFS, LocalStorage, MountableFileSystem, OverlayFS, WorkerFS, HTTPRequest, ZipFS].forEach((fsType: FileSystemConstructor) => {

                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  src/core/file_system.ts:384:3
    384   CreateAsync(options: object): Promise<FileSystem>;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'CreateAsync' is declared here.

src/core/backends.ts:45:7 - error TS2322: Type '{ AsyncMirror: typeof AsyncMirror; Dropbox: typeof DropboxFileSystem; Emscripten: typeof EmscriptenFileSystem; FileSystemAccess: typeof FileSystemAccessFileSystem; FolderAdapter: typeof FolderAdapter; HTML5FS: typeof HTML5FS; ... 9 more ...; ZipFS: typeof ZipFS; }' is not assignable to type '{ [name: string]: FileSystemConstructor; }'.
  Property 'FileSystemAccess' is incompatible with index signature.
    Type 'typeof FileSystemAccessFileSystem' is not assignable to type 'FileSystemConstructor'.

45 const _: {[name: string]: FileSystemConstructor} = Backends;
         ~

Found 23 errors.

ERROR: "build:tsc" exited with 2.
ERROR: "build" exited with 1.
error Command failed with exit code 1.
james-pre commented 1 year ago

@DustinBrett The FileSystemAccess backend does not implement Cred. I'm not sure why it was merged if there were build errors.

I can take a look at updating FileSystemAccess to correctly implement Cred.

DustinBrett commented 1 year ago

Ya I don't think the builds have passed in a while, doesn't seem to stop merges. I half put my PR up to get a discussion going about if anything needed changing, but it's been merged with quite a few others. I will also look at if there is anything I can PR a fix for. As it is I use a custom build anyway, but I was following this repo in my package.json for typing purposes and I've had to lock that to an older commit until this is resolved.

emeryberger commented 1 year ago

I can see about backing out your PR to see if it helps. Which one was it?

DustinBrett commented 1 year ago

I can see about backing out your PR to see if it helps. Which one was it?

Thanks for the offer but perhaps we can just walk back to before build errors. My PR at one point was fine I think, can we step back Cred or merge a PR to add support for this new feature to all current backends?

emeryberger commented 1 year ago

I just merged a PR by @james-pre that adds Cred so please see if that helps!

james-pre commented 1 year ago

@emeryberger I was just about to mention that...

On the topic of building, I think we should take a look at updating the CI/CD setup. I use Azure Pipelines for a few projects and think it could work really well (plus reducing all the packages for Karma and Travis CI)

emeryberger commented 1 year ago

Updating the CI setup would be great - I will happily merge them. I'd love to get us back to passing the CI tests.

emeryberger commented 1 year ago

@DustinBrett any news?

DustinBrett commented 1 year ago

I'm not sure about that change to Cred which looks to have changed the API in general. Hopefully that isn't the case as the callback being the 2nd argument is something in most codebases I'd imagine already.

I haven't had time to look into much of the issues since this merge. I think maybe too much got merged in general. Feel free to disable my backend until all the build issues are fixed, but if the API has changed because of Cred, I will likely stop upgrading for a while until I see a reason to.

james-pre commented 1 year ago

@DustinBrett With Cred, only the internal BFS API has changed. Externally, it still behaves just like Node's. In addition, if you want to use a different uid/gid for the external BFS API you can do something like this:


BrowserFS.FileSystem.InMemory.Create((err, inMem) => {
    BrowserFS.initalize(inMem, uid, gid);
});
const fs = BrowserFS.BFSRequire('fs');

Edit: Also, if you want I can open a PR to add uid/gid as an option to configure/configureAsync.

DustinBrett commented 1 year ago

That's good to hear. Sorry I haven't dug into it further. I typically use a custom build so I haven't followed the repo too much other than using it for typings. Hopefully that latest PR helped with build issues, but the health of the project in general needs fixing probably and then the CI being green and no more merges unless it stays green.

james-pre commented 1 year ago

@DustinBrett This should be resolved since #345 and #347 got merged. Please reach out if it isn't.