Skip to content

Commit 9db212c

Browse files
committed
feat(catalog): bundle externals.json into the archive
1 parent 098e7ec commit 9db212c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/apps/catalog/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default class CatalogApp implements App {
127127
${this.config.declarations.map(d => d.js).join('\n')}
128128
129129
`;
130-
130+
131131
await promisify(writeFile.bind(null,
132132
join(this.config.dir, '.catalog.entry.js'),
133133
js,
@@ -184,6 +184,9 @@ export default class CatalogApp implements App {
184184
if (existsSync(root('docs/schemas'))) {
185185
archive.directory(root('docs/schemas'), 'schemas');
186186
}
187+
188+
let externals = JSON.stringify(this.support.externals);
189+
archive.append(externals, { name: 'pie-pkg/externals.json' });
187190
}
188191

189192
let ignores = archiveIgnores(this.config.dir);

test/unit/apps/catalog/index-test.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import proxyquire from 'proxyquire';
44

55
describe('catalog', () => {
66

7-
let mod, deps, catalog, NAMES;
7+
let mod, deps, catalog, NAMES, support;
88

99
beforeEach(() => {
1010

@@ -33,6 +33,13 @@ describe('catalog', () => {
3333

3434
mod = proxyquire('../../../../lib/apps/catalog', deps);
3535

36+
support = {
37+
externals: {
38+
js: ['external.js'],
39+
css: ['external.css']
40+
}
41+
}
42+
3643
catalog = new mod.default({
3744
configuration: {
3845
app: {
@@ -42,7 +49,9 @@ describe('catalog', () => {
4249
}, 'pieRoot', {
4350
dir: 'dir',
4451
declarations: []
45-
}, {}, {
52+
},
53+
support,
54+
{
4655
build: {
4756
entryFile: '.all-in-one.entry.js'
4857
},
@@ -114,7 +123,8 @@ describe('catalog', () => {
114123
let init = (exists, done) => {
115124
archive = {
116125
file: stub(),
117-
directory: stub()
126+
directory: stub(),
127+
append: stub()
118128
}
119129
deps['fs-extra'].existsSync.returns(exists);
120130
deps['../create-archive'].createArchive = spy(
@@ -148,6 +158,10 @@ describe('catalog', () => {
148158
assert.calledWith(archive.directory, match(/.*docs\/schemas$/), 'schemas');
149159
});
150160

161+
it('calls archive.append for externals.json', () => {
162+
assert.calledWith(archive.append, JSON.stringify(support.externals), { name: 'pie-pkg/externals.json' });
163+
});
164+
151165
describe('when schemas does not exist', () => {
152166
beforeEach((done) => {
153167
init(false, done);

0 commit comments

Comments
 (0)