Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Commit

Permalink
[Fix] Lerna should work on ./packages/**/dist/.
Browse files Browse the repository at this point in the history
Lerna should only publish outcome of ng-packagr.
Configured Lerna to operate on the dist/ folder of a package.
  • Loading branch information
about-code committed Sep 23, 2017
1 parent 36bd188 commit 89b99be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion generators/project-app/template/lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"lerna": "2.1.2",
"packages": [
"packages/**/*"
"packages/**/dist/"
],
"version": "independent"
}
35 changes: 19 additions & 16 deletions generators/project-app/template/scripts/build-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,36 @@ const path = require('path');
const rimraf = require('rimraf');
const ngPackagr = require('../node_modules/ng-packagr/lib/ng-packagr');

process.env.DEBUG = true;

function dirs(base) {
/**
* @return List of sub-directories of `base` directory
*/
function subDirectories(base) {
return fs
.readdirSync(base)
.map(file => path.resolve(base, file))
.filter(file => fs.lstatSync(file).isDirectory());
}

var PATHS = [];
const PACKAGE_SRC_DIR = path.resolve(__dirname, '../packages');
const PACKAGES_OR_SCOPES = dirs(PACKAGE_SRC_DIR).forEach((dir) => {
PATHS = [...PATHS, dir, ...dirs(dir)];
});
let paths = [];
let tasks = [];

var PACKAGES = PATHS
.filter(file => fs.existsSync(path.resolve(file, 'ng-package.json')));
const PACKAGE_DIR = path.resolve(__dirname, '../packages');
const PACKAGES_OR_SCOPES = subDirectories(PACKAGE_DIR).forEach((dir) => {
paths = [...paths, dir, ...subDirectories(dir)];
});
const PACKAGES = paths.filter(dir => {
return fs.existsSync(path.resolve(dir, 'ng-package.json'))
});

let promise = Promise.resolve();
let tasks = [];
while (PACKAGES.length > 0) {
const package = PACKAGES.pop();
for (let i = 0, len = PACKAGES.length; i < len; i++) {
const package = PACKAGES[i];
const project = path.join(package, 'ng-package.json');

// delete previous dist
rimraf.sync(path.join(package, 'dist'));

tasks.push(
ngPackagr.ngPackage({ project })
tasks.push(ngPackagr
.ngPackage({ project })
.then(() => rimraf.sync(path.join(package, '.ng_build')))
.catch((err) => {
console.error(`Failed to package "${package}". Cause: `, err);
Expand Down

0 comments on commit 89b99be

Please sign in to comment.