stevedlawrence commented on issue #1139:
URL: 
https://github.com/apache/daffodil-vscode/issues/1139#issuecomment-2521159598

   For reference, this patch to vscode-vsce seems to fix it so it can create 
reproducible zips by sorting the files and using SOURCE_DATE_EPOCH if defined:
   
   ```diff
   diff --git a/src/package.ts b/src/package.ts
   index d27b71c..9416b45 100644
   --- a/src/package.ts
   +++ b/src/package.ts
   @@ -1800,13 +1800,21 @@ function writeVsix(files: IFile[], packagePath: 
string): Promise<void> {
                        () =>
                                new Promise((c, e) => {
                                        const zip = new yazl.ZipFile();
   -                                    files.forEach(f =>
   +
   +                                    const sde = 
process.env.SOURCE_DATE_EPOCH;
   +                                    const epoch = sde ? parseInt(sde) : 
undefined;
   +                                    const mtime = epoch ? new Date(epoch * 
1000) : undefined;
   +
   +                                    files.sort((a, b) => 
a.path.localeCompare(b.path)).forEach(f => {
   +                                            let options = {
   +                                                    mode: f.mode,
   +                                            } as any;
   +                                            if (mtime) options.mtime = 
mtime;
   +
                                                isInMemoryFile(f)
   -                                                    ? zip.addBuffer(typeof 
f.contents === 'string' ? Buffer.from(f.contents, 'utf8') : f.contents, f.path, 
{
   -                                                            mode: f.mode,
   -                                                    })
   -                                                    : 
zip.addFile(f.localPath, f.path, { mode: f.mode })
   -                                    );
   +                                                    ? zip.addBuffer(typeof 
f.contents === 'string' ? Buffer.from(f.contents, 'utf8') : f.contents, f.path, 
options)
   +                                                    : 
zip.addFile(f.localPath, f.path, options)
   +                                    });
                                        zip.end();
    
                                        const zipStream = 
fs.createWriteStream(packagePath);
   ```
   
   I imagine there's a cleaner syntax to deal with the `undefined` stuff, but 
otherwise this seems fairly straightfoward and maybe something vscode-vsce 
would be willing to accept.
   
   I think the question is if we did try to upstream this to vscode-vsce, would 
daffodil-vscode be able to update to the newer version, or is there a reason we 
need to stick with an older version.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to