
committed by
Igor Minar

parent
344a5ca545
commit
9bbf009dff
@ -7,25 +7,44 @@ const yargs = require('yargs');
|
||||
const SHARED_PATH = path.resolve(__dirname, 'shared');
|
||||
const SHARED_NODE_MODULES_PATH = path.resolve(SHARED_PATH, 'node_modules');
|
||||
const BOILERPLATE_BASE_PATH = path.resolve(SHARED_PATH, 'boilerplate');
|
||||
const BOILERPLATE_COMMON_BASE_PATH = path.resolve(BOILERPLATE_BASE_PATH, 'common');
|
||||
const EXAMPLES_BASE_PATH = path.resolve(__dirname, '../../content/examples');
|
||||
const TESTING_BASE_PATH = path.resolve(EXAMPLES_BASE_PATH, 'testing');
|
||||
|
||||
const BOILERPLATE_SRC_PATHS = [
|
||||
'src/styles.css',
|
||||
'src/systemjs-angular-loader.js',
|
||||
'src/systemjs.config.js',
|
||||
'src/tsconfig.json',
|
||||
'bs-config.json',
|
||||
'bs-config.e2e.json',
|
||||
'package.json',
|
||||
'tslint.json'
|
||||
];
|
||||
|
||||
const BOILERPLATE_TEST_PATHS = [
|
||||
'src/browser-test-shim.js',
|
||||
'karma-test-shim.js',
|
||||
'karma.conf.js'
|
||||
];
|
||||
const BOILERPLATE_PATHS = {
|
||||
cli: [
|
||||
'src/environments/environment.prod.ts',
|
||||
'src/environments/environment.ts',
|
||||
'src/assets/.gitkeep',
|
||||
'src/favicon.ico',
|
||||
'src/polyfills.ts',
|
||||
'src/test.ts',
|
||||
'src/tsconfig.app.json',
|
||||
'src/tsconfig.spec.json',
|
||||
'src/typings.d.ts',
|
||||
'e2e/app.po.ts',
|
||||
'e2e/tsconfig.e2e.json',
|
||||
'.angular-cli.json',
|
||||
'.editorconfig',
|
||||
'karma.conf.js',
|
||||
'package.json',
|
||||
'protractor.conf.js',
|
||||
'tsconfig.json',
|
||||
'tslint.json'
|
||||
],
|
||||
systemjs: [
|
||||
'src/systemjs-angular-loader.js',
|
||||
'src/systemjs.config.js',
|
||||
'src/tsconfig.json',
|
||||
'bs-config.json',
|
||||
'bs-config.e2e.json',
|
||||
'package.json',
|
||||
'tslint.json'
|
||||
],
|
||||
common: [
|
||||
'src/styles.css'
|
||||
]
|
||||
};
|
||||
|
||||
const ANGULAR_DIST_PATH = path.resolve(__dirname, '../../../dist');
|
||||
const ANGULAR_PACKAGES_PATH = path.resolve(ANGULAR_DIST_PATH, 'packages-dist');
|
||||
@ -64,19 +83,20 @@ class ExampleBoilerPlate {
|
||||
// Get all the examples folders, indicated by those that contain a `example-config.json` file
|
||||
const exampleFolders = this.getFoldersContaining(EXAMPLES_BASE_PATH, EXAMPLE_CONFIG_FILENAME, 'node_modules');
|
||||
exampleFolders.forEach(exampleFolder => {
|
||||
const exampleConfig = this.loadJsonFile(path.resolve(exampleFolder, EXAMPLE_CONFIG_FILENAME));
|
||||
|
||||
// Link the node modules - requires admin access (on Windows) because it adds symlinks
|
||||
const destinationNodeModules = path.resolve(exampleFolder, 'node_modules');
|
||||
fs.ensureSymlinkSync(SHARED_NODE_MODULES_PATH, destinationNodeModules);
|
||||
|
||||
// Copy the boilerplate source files
|
||||
BOILERPLATE_SRC_PATHS.forEach(filePath => this.copyFile(BOILERPLATE_BASE_PATH, exampleFolder, filePath));
|
||||
const boilerPlateType = exampleConfig.projectType || 'cli';
|
||||
const boilerPlateBasePath = path.resolve(BOILERPLATE_BASE_PATH, boilerPlateType);
|
||||
|
||||
// Copy the boilerplate test files (if the example is configured to do unit testing)
|
||||
const exampleConfig = this.loadJsonFile(path.resolve(exampleFolder, EXAMPLE_CONFIG_FILENAME));
|
||||
if (exampleConfig.unittesting) {
|
||||
BOILERPLATE_TEST_PATHS.forEach(filePath => this.copyFile(TESTING_BASE_PATH, exampleFolder, filePath));
|
||||
}
|
||||
// Copy the boilerplate specific files
|
||||
BOILERPLATE_PATHS[boilerPlateType].forEach(filePath => this.copyFile(boilerPlateBasePath, exampleFolder, filePath));
|
||||
|
||||
// Copy the boilerplate common files
|
||||
BOILERPLATE_PATHS.common.forEach(filePath => this.copyFile(BOILERPLATE_COMMON_BASE_PATH, exampleFolder, filePath));
|
||||
});
|
||||
}
|
||||
|
||||
@ -132,4 +152,4 @@ module.exports = new ExampleBoilerPlate();
|
||||
// If this file was run directly then run the main function,
|
||||
if (require.main === module) {
|
||||
module.exports.main();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user