build(aio): copy content image assets
This commit is contained in:
parent
08941aa0c7
commit
dd4e3f8704
@ -24,7 +24,8 @@ const API_SOURCE_PATH = path.resolve(PROJECT_ROOT, 'packages');
|
|||||||
const AIO_PATH = path.resolve(PROJECT_ROOT, 'aio');
|
const AIO_PATH = path.resolve(PROJECT_ROOT, 'aio');
|
||||||
const CONTENTS_PATH = path.resolve(AIO_PATH, 'content');
|
const CONTENTS_PATH = path.resolve(AIO_PATH, 'content');
|
||||||
const TEMPLATES_PATH = path.resolve(AIO_PATH, 'transforms/templates');
|
const TEMPLATES_PATH = path.resolve(AIO_PATH, 'transforms/templates');
|
||||||
const OUTPUT_PATH = path.resolve(AIO_PATH, 'src/content/docs');
|
const OUTPUT_PATH = path.resolve(AIO_PATH, 'src/content');
|
||||||
|
const DOCS_OUTPUT_PATH = path.resolve(OUTPUT_PATH, 'docs');
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
new Package(
|
new Package(
|
||||||
@ -51,11 +52,12 @@ module.exports =
|
|||||||
.processor(require('./processors/filterIgnoredDocs'))
|
.processor(require('./processors/filterIgnoredDocs'))
|
||||||
.processor(require('./processors/fixInternalDocumentLinks'))
|
.processor(require('./processors/fixInternalDocumentLinks'))
|
||||||
.processor(require('./processors/processNavigationMap'))
|
.processor(require('./processors/processNavigationMap'))
|
||||||
|
.processor(require('./processors/copyContentAssets'))
|
||||||
|
|
||||||
// overrides base packageInfo and returns the one for the 'angular/angular' repo.
|
// overrides base packageInfo and returns the one for the 'angular/angular' repo.
|
||||||
.factory('packageInfo', function() { return require(path.resolve(PROJECT_ROOT, 'package.json')); })
|
.factory('packageInfo', function() { return require(path.resolve(PROJECT_ROOT, 'package.json')); })
|
||||||
|
|
||||||
.factory(require('./readers/json'))
|
.factory(require('./readers/json'))
|
||||||
|
.factory(require('./services/copyFolder'))
|
||||||
|
|
||||||
.config(function(checkAnchorLinksProcessor, log) {
|
.config(function(checkAnchorLinksProcessor, log) {
|
||||||
// TODO: re-enable
|
// TODO: re-enable
|
||||||
@ -168,7 +170,7 @@ module.exports =
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Where do we write the output files?
|
// Where do we write the output files?
|
||||||
.config(function(writeFilesProcessor) { writeFilesProcessor.outputFolder = OUTPUT_PATH; })
|
.config(function(writeFilesProcessor) { writeFilesProcessor.outputFolder = DOCS_OUTPUT_PATH; })
|
||||||
|
|
||||||
|
|
||||||
// Target environments
|
// Target environments
|
||||||
@ -292,6 +294,12 @@ module.exports =
|
|||||||
convertToJsonProcessor.docTypes = EXPORT_DOC_TYPES.concat([
|
convertToJsonProcessor.docTypes = EXPORT_DOC_TYPES.concat([
|
||||||
'content', 'decorator', 'directive', 'pipe', 'module'
|
'content', 'decorator', 'directive', 'pipe', 'module'
|
||||||
]);
|
]);
|
||||||
|
})
|
||||||
|
|
||||||
|
.config(function(copyContentAssetsProcessor) {
|
||||||
|
copyContentAssetsProcessor.assetMappings.push(
|
||||||
|
{ from: path.resolve(CONTENTS_PATH, 'images'), to: path.resolve(OUTPUT_PATH, 'images') }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
module.exports = function copyContentAssetsProcessor(copyFolder) {
|
||||||
|
return {
|
||||||
|
$runAfter: ['files-written'],
|
||||||
|
assetMappings: [],
|
||||||
|
$process() {
|
||||||
|
this.assetMappings.forEach(map => {
|
||||||
|
copyFolder(map.from, map.to);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,27 @@
|
|||||||
|
const testPackage = require('../../helpers/test-package');
|
||||||
|
const Dgeni = require('dgeni');
|
||||||
|
const factory = require('./copyContentAssets');
|
||||||
|
|
||||||
|
fdescribe('extractDecoratedClasses processor', function() {
|
||||||
|
let dgeni, injector, processor;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
dgeni = new Dgeni([testPackage('angular.io-package')]);
|
||||||
|
injector = dgeni.configureInjector();
|
||||||
|
processor = injector.get('copyContentAssetsProcessor');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should exist', () => {
|
||||||
|
expect(processor).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call copyFolder with each mapping', () => {
|
||||||
|
const mockCopyFolder = jasmine.createSpy();
|
||||||
|
processor = factory(mockCopyFolder);
|
||||||
|
processor.assetMappings.push({ from: 'a/b/c', to: 'x/y/z' });
|
||||||
|
processor.assetMappings.push({ from: '1/2/3', to: '4/5/6' });
|
||||||
|
processor.$process();
|
||||||
|
expect(mockCopyFolder).toHaveBeenCalledWith('a/b/c', 'x/y/z');
|
||||||
|
expect(mockCopyFolder).toHaveBeenCalledWith('1/2/3', '4/5/6');
|
||||||
|
});
|
||||||
|
});
|
5
aio/transforms/angular.io-package/services/copyFolder.js
Normal file
5
aio/transforms/angular.io-package/services/copyFolder.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const {cp} = require('shelljs');
|
||||||
|
|
||||||
|
module.exports = function copyFolder() {
|
||||||
|
return (from, to) => cp('-rf', from, to);
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user