Skip to content

Commit

Permalink
Correct dependency cycle
Browse files Browse the repository at this point in the history
Applies the short-term strategy described in aws#31 by taking an
un-modelled dependency on aws-cdk-docs and displaying an error
message with instructions to install aws-cdk-docs if it cannot
be resolved when cdk docs is invoked.
  • Loading branch information
RomainMuller committed Jun 5, 2018
1 parent 860e788 commit c614b1b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export PATH=node_modules/.bin:$PATH

echo "============================================================================================="
echo "boostrapping..."
lerna bootstrap --loglevel=debug
lerna bootstrap --reject-cycles --loglevel=debug

echo "============================================================================================="
echo "testing..."
Expand Down
6 changes: 3 additions & 3 deletions bundle-beta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ rsync -aL ${root}/local-npm/*.tgz repo/npm # jsii modules
mkdir -p repo/maven
cp ${root}/packages/aws-cdk-java/target/*.jar repo/maven

# Deploy the docs website to docs/
rsync -a ${root}/packages/aws-cdk-docs/dist/docs/ ./docs

# Bootstrap a production-ready node_modules closure with all npm modules (jsii and CDK)
npm install --global-style --production --no-save repo/npm/*.tgz

# Symlink 'bin' to the root
ln -s node_modules/.bin bin

# Symlink the docs website to docs
ln -s node_modules/aws-cdk-docs/dist/docs docs

# Create an archive under ./dist
version="$(cat ${root}/lerna.json | grep version | cut -d '"' -f4)"
dist=${root}/dist
Expand Down
15 changes: 12 additions & 3 deletions packages/aws-cdk-toolkit/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import 'source-map-support/register';

import * as cxapi from 'aws-cdk-cx-api';
import { documentationIndexPath } from 'aws-cdk-docs';
import { deepMerge, isEmpty, partition } from 'aws-cdk-util';
import { exec, spawn } from 'child_process';
import { blue, green } from 'colors/safe';
Expand Down Expand Up @@ -206,10 +205,20 @@ function printWarnings(stacks: cxapi.SynthesizeResponse) {
return found;
}

async function openDocsite(commandTemplate: string) {
async function openDocsite(commandTemplate: string): Promise<number> {
let documentationIndexPath: string;
try {
// tslint:disable-next-line:no-var-require Taking an un-declared dep on aws-cdk-docs, to avoid a dependency circle
const docs = require('aws-cdk-docs');
documentationIndexPath = docs.documentationIndexPath;
} catch (err) {
error('Unable to open CDK documentation - the aws-cdk-docs package appears to be missing. Please run `npm install -g aws-cdk-docs`');
return -1;
}

const browserCommand = commandTemplate.replace(/%u/g, documentationIndexPath);
debug(`Opening documentation ${green(browserCommand)}`);
return await new Promise((resolve, reject) => {
return await new Promise<number>((resolve, reject) => {
exec(browserCommand, (err, stdout, stderr) => {
if (err) { return reject(err); }
if (stdout) { debug(stdout); }
Expand Down
1 change: 0 additions & 1 deletion packages/aws-cdk-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"aws-cdk": "^0.6.0",
"aws-cdk-cloudformation-diff": "^0.6.0",
"aws-cdk-cx-api": "^0.6.0",
"aws-cdk-docs": "^0.6.0",
"aws-cdk-resources": "^0.6.0",
"aws-cdk-util": "^0.6.0",
"aws-sdk": "^2.135.0",
Expand Down

0 comments on commit c614b1b

Please sign in to comment.