-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): create Zip from project #235
Conversation
Pull Request Report PR Title ✅ Title follows the conventional commit spec. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did an early sneak peak between two builds ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes in the mocks :)
Co-authored-by: Louis Bompart <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to streamline and avoid casting in the mocks
const doMockAuthenticatedClient = () => { | ||
mockedAuthenticatedClient.mockImplementation( | ||
() => | ||
({ | ||
getClient: () => | ||
Promise.resolve({ | ||
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | ||
}), | ||
} as unknown as AuthenticatedClient) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const doMockAuthenticatedClient = () => { | |
mockedAuthenticatedClient.mockImplementation( | |
() => | |
({ | |
getClient: () => | |
Promise.resolve({ | |
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | |
}), | |
} as unknown as AuthenticatedClient) | |
); | |
}; | |
const doMockAuthenticatedClient = () => { | |
mockedAuthenticatedClient.prototype.getClient.mockImplementation(() => | |
Promise.resolve({ | |
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | |
}) | |
); | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it still causes the same error. Now the resourceSnapshot
mock is missing all its methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yeah, the PlatformClient
was missing some stuff.
Double check but I think this would work tho
const doMockAuthenticatedClient = () => { | |
mockedAuthenticatedClient.mockImplementation( | |
() => | |
({ | |
getClient: () => | |
Promise.resolve({ | |
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | |
}), | |
} as unknown as AuthenticatedClient) | |
); | |
}; | |
const doMockAuthenticatedClient = () => | |
mockedAuthenticatedClient.prototype.getClient.mockImplementation(() => | |
Promise.resolve<PlatformClient>({ | |
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | |
} as unknown as PlatformClient) | |
); | |
Co-authored-by: Louis Bompart <[email protected]>
Co-authored-by: Louis Bompart <[email protected]>
Co-authored-by: Louis Bompart <[email protected]>
const doMockAuthenticatedClient = () => { | ||
mockedAuthenticatedClient.mockImplementation( | ||
() => | ||
({ | ||
getClient: () => | ||
Promise.resolve({ | ||
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | ||
}), | ||
} as unknown as AuthenticatedClient) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yeah, the PlatformClient
was missing some stuff.
Double check but I think this would work tho
const doMockAuthenticatedClient = () => { | |
mockedAuthenticatedClient.mockImplementation( | |
() => | |
({ | |
getClient: () => | |
Promise.resolve({ | |
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | |
}), | |
} as unknown as AuthenticatedClient) | |
); | |
}; | |
const doMockAuthenticatedClient = () => | |
mockedAuthenticatedClient.prototype.getClient.mockImplementation(() => | |
Promise.resolve<PlatformClient>({ | |
resourceSnapshot: {createFromFile: mockedCreateSnapshotFromFile}, | |
} as unknown as PlatformClient) | |
); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be more syntactically correct to do a default import ;)
import {existsSync, createWriteStream, WriteStream, unlinkSync} from 'fs'; | ||
import {Project} from './project'; | ||
import {join} from 'path'; | ||
import * as archiver from 'archiver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mh, I would enable esModuleInterop
in the tsconfig and do
import * as archiver from 'archiver'; | |
import archiver, {Archiver} from 'archiver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it will work in this case since there are no default export in the archiver package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oups, I updated the wrong tsconfig 🤦
pipe: mockedPipe, | ||
directory: mockedPassDirectory, | ||
finalize: mockedFinalize, | ||
} as unknown as archiver.Archiver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do my suggestion above
} as unknown as archiver.Archiver) | |
} as unknown as Archiver) |
import {createWriteStream, existsSync, unlinkSync} from 'fs'; | ||
import {join} from 'path'; | ||
import {cli} from 'cli-ux'; | ||
import * as archiver from 'archiver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import * as archiver from 'archiver'; | |
import archiver from 'archiver'; |
Proposed changes
Reads the project, compress the resources into a single zip and use it to create a snapshot.
The command uses a third party library to compress the resources. I initially tried using the native
zlib
API but it seems to only support single file compression. We can probably achieve the same result with some stream manipulation but, I am keeping it simple for now.Testing
CDX-353