Skip to content

Commit

Permalink
feat: version in distribution manifest (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjozork authored Sep 8, 2024
1 parent 459c6e3 commit 589bd98
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 80 deletions.
77 changes: 19 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/install/fragmenter-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ describe('FragmenterInstaller', () => {

installer.on('error', (e) => console.error(e));

setTimeout(() => {
const timeout = setTimeout(() => {
abortController.abort();
}, 3_000);

await installer.install();

clearTimeout(timeout);
});
});
42 changes: 23 additions & 19 deletions src/pack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@ import { pack } from './index';

jest.setTimeout(720_000);

test('Pack', async () => {
const result = await pack({
baseDir: './tests/in/pack-01',
outDir: './tests/out/pack-01',
modules: [{
name: 'a',
sourceDir: './a',
}, {
name: 'b',
sourceDir: './b',
}, {
name: 'c',
sourceDir: './c',
}],
});
describe('packer', () => {
test('pack', async () => {
const result = await pack({
version: '0.1.0',
baseDir: './tests/in/pack-01',
outDir: './tests/out/pack-01',
modules: [{
name: 'a',
sourceDir: './a',
}, {
name: 'b',
sourceDir: './b',
}, {
name: 'c',
sourceDir: './c',
}],
});

expect(result.fullHash).toBe('7a8192768029ad9bd0aff064df12568aeea22573fe12eda88898687232e8cefdb759bf2cbd7795fa5840be1c6886025b86d621c76869df996a18260c535c761c');
expect(result.base.hash).toBe('c66ac1e5c010060c460d72ee94034f0fff3dffc9ef762502611876fcba444c9d7b5a761952a906175db7e96243b8d93651a0468d3e768709eb7895f36c35ad67');
expect(result.base.files).toEqual(['a.json', 'module.json']);
expect(result.modules).toHaveLength(3);
expect(result.version).toBe('0.1.0');
expect(result.fullHash).toBe('7a8192768029ad9bd0aff064df12568aeea22573fe12eda88898687232e8cefdb759bf2cbd7795fa5840be1c6886025b86d621c76869df996a18260c535c761c');
expect(result.base.hash).toBe('c66ac1e5c010060c460d72ee94034f0fff3dffc9ef762502611876fcba444c9d7b5a761952a906175db7e96243b8d93651a0468d3e768709eb7895f36c35ad67');
expect(result.base.files).toEqual(['a.json', 'module.json']);
expect(result.modules).toHaveLength(3);
});
});
3 changes: 1 addition & 2 deletions src/packer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import fs from 'fs-extra';
import { Zip } from 'zip-lib';
import SplitFile from 'split-file';
import path from 'path';
// eslint-disable-next-line import/no-unresolved
import readRecurse from 'fs-readdir-recursive';
// eslint-disable-next-line import/no-unresolved
import hasha from 'hasha';
import {
BuildManifest,
Expand Down Expand Up @@ -174,6 +172,7 @@ export async function pack(buildManifest: BuildManifest): Promise<DistributionMa
fs.copySync(buildManifest.baseDir, tempDir);

const distributionManifest: DistributionManifest = {
version: buildManifest.version,
modules: [],
base: {
hash: '',
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ export interface Base {
}

export interface BuildManifest {
version: string;
baseDir: string;
outDir: string;
packOptions?: PackOptions;
modules: Module[];
}

export interface DistributionManifest {
version?: string;
modules: DistributionModule[];
base: Base;
fullHash: string;
Expand Down

0 comments on commit 589bd98

Please sign in to comment.