-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: use new manifest format * chore: fix test * chore: add test * refactor: add Manifest type * feat: update bootstrap layer
- Loading branch information
1 parent
a3906d4
commit 7bee912
Showing
8 changed files
with
151 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
interface Bundle { | ||
extension: string | ||
format: string | ||
hash: string | ||
} | ||
|
||
export type { Bundle } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { createRequire } from 'module' | ||
|
||
const require = createRequire(import.meta.url) | ||
const pkgJson = require('../package.json') | ||
|
||
const getPackageVersion = (): string => pkgJson.version | ||
|
||
export { getPackageVersion } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { env } from 'process' | ||
|
||
import test from 'ava' | ||
|
||
import { generateManifest } from '../src/manifest.js' | ||
|
||
test('Generates a manifest with different bundles', (t) => { | ||
const bundle1 = { | ||
extension: '.ext1', | ||
format: 'format1', | ||
hash: '123456', | ||
} | ||
const bundle2 = { | ||
extension: '.ext2', | ||
format: 'format2', | ||
hash: '654321', | ||
} | ||
const functions = [{ name: 'func-1', path: '/path/to/func-1.ts' }] | ||
const declarations = [{ function: 'func-1', path: '/f1' }] | ||
const manifest = generateManifest({ bundles: [bundle1, bundle2], declarations, functions }) | ||
|
||
const expectedBundles = [ | ||
{ asset: bundle1.hash + bundle1.extension, format: bundle1.format }, | ||
{ asset: bundle2.hash + bundle2.extension, format: bundle2.format }, | ||
] | ||
const expectedRoutes = [{ function: 'func-1', pattern: '^/f1$' }] | ||
|
||
t.deepEqual(manifest.bundles, expectedBundles) | ||
t.deepEqual(manifest.routes, expectedRoutes) | ||
t.is(manifest.bundler_version, env.npm_package_version as string) | ||
}) | ||
|
||
test('Excludes functions for which there are function files but no matching config declarations', (t) => { | ||
const bundle1 = { | ||
extension: '.ext2', | ||
format: 'format1', | ||
hash: '123456', | ||
} | ||
const functions = [ | ||
{ name: 'func-1', path: '/path/to/func-1.ts' }, | ||
{ name: 'func-2', path: '/path/to/func-2.ts' }, | ||
] | ||
const declarations = [{ function: 'func-1', path: '/f1' }] | ||
const manifest = generateManifest({ bundles: [bundle1], declarations, functions }) | ||
|
||
const expectedRoutes = [{ function: 'func-1', pattern: '^/f1$' }] | ||
|
||
t.deepEqual(manifest.routes, expectedRoutes) | ||
}) | ||
|
||
test('Excludes functions for which there are config declarations but no matching function files', (t) => { | ||
const bundle1 = { | ||
extension: '.ext2', | ||
format: 'format1', | ||
hash: '123456', | ||
} | ||
const functions = [{ name: 'func-2', path: '/path/to/func-2.ts' }] | ||
const declarations = [ | ||
{ function: 'func-1', path: '/f1' }, | ||
{ function: 'func-2', path: '/f2' }, | ||
] | ||
const manifest = generateManifest({ bundles: [bundle1], declarations, functions }) | ||
|
||
const expectedRoutes = [{ function: 'func-2', pattern: '^/f2$' }] | ||
|
||
t.deepEqual(manifest.routes, expectedRoutes) | ||
}) | ||
|
||
test('Generates a manifest without bundles', (t) => { | ||
const functions = [{ name: 'func-1', path: '/path/to/func-1.ts' }] | ||
const declarations = [{ function: 'func-1', path: '/f1' }] | ||
const manifest = generateManifest({ bundles: [], declarations, functions }) | ||
|
||
const expectedRoutes = [{ function: 'func-1', pattern: '^/f1$' }] | ||
|
||
t.deepEqual(manifest.bundles, []) | ||
t.deepEqual(manifest.routes, expectedRoutes) | ||
t.is(manifest.bundler_version, env.npm_package_version as string) | ||
}) |