Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules/
.BUILD_COMPLETED
lerna-debug.log
tsconfig.tsbuildinfo
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ script:
# Building the Docker image
- docker build --pull --build-arg BUILD_TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg COMMIT_ID="${TRAVIS_COMMIT}" -t "jsii/superchain:nightly" ./superchain
# Building jsii itself within the Docker image
- docker run --rm -it --net=host -v ${PWD}:${PWD} -w ${PWD} jsii/superchain:nightly ./build.sh
- docker run --rm -it --net=host -v ${PWD}:${PWD} -w ${PWD} jsii/superchain:nightly npm run build
# Make sure the build did not change the source tree
- git update-index --refresh
- git diff-index --exit-code --stat HEAD
Expand Down
19 changes: 11 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ cd jsii # go to the root of the jsii repo
$ docker run --rm --net=host -it -v $PWD:$PWD -w $PWD ${IMAGE}
```

You can then run `./build.sh` as described below.
You can then run `npm run build` as described below.

## Getting Started
### Bootstrapping
Expand All @@ -59,7 +59,7 @@ The project is managed as a [monorepo] using [lerna].
[lerna]: https://github.com/lerna/lerna

1. Check out this repository.
2. Run `./build.sh` to install lerna, bootstrap the repository and perform an
2. Run `npm run build` to install lerna, bootstrap the repository and perform an
initial build and test cycle.

### Development Workflow
Expand All @@ -78,20 +78,23 @@ Each one of these scripts can be executed either from the root of the repo using

### Bump

To bump the version of this repository, use the [`./bump.sh`](./bump.sh) script.
To bump the version of this repository, use the [`npm run bump`] script.

[`npm run bump`]: ./scripts/bump.sh

### Packaging and Bundling

This repository emits artifacts in multiple languages. The
[`pack.sh`](./pack.sh) and [`bundle.sh`](./bundle.sh) scripts are used to
prepare the repository for publishing.
This repository emits artifacts in multiple languages. The [`npm run package`]
script is used to prepare the repository for publishing.

[`npm run package`]: ./scripts/package.sh

Each module that needs to be published implements an npm script called `package`
which emits publishable artifacts to `dist/<lang>` (e.g. `dist/dotnet` for
NuGet, `dist/js` for npm, `dist/java` for Maven Central). All those "dist"
directories are merged into a single .zip file that is later on used in our
CI/CD publishing tasks. Each `lang` directory is published to the respective
repository.
CI/CD publishing tasks. Each `<lang>` directory is published to the respective
package repository.

## Implementing Language Bindings

Expand Down
8 changes: 4 additions & 4 deletions buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ version: 0.2
phases:
install:
commands:
- /bin/bash ./install.sh
- npm run bootstrap
pre_build:
commands:
- /bin/bash ./fetch-dotnet-snk.sh
- npm run fetch-dotnet-snk
build:
commands:
- /bin/bash ./build.sh
- npm run build
post_build:
commands:
- "[ -f .BUILD_COMPLETED ] && /bin/bash ./pack.sh"
- '[ ${CODEBUILD_BUILD_SUCCEEDING} = 1 ] && npm run package'
artifacts:
files:
- "**/*"
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 22 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"private": true,
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^8.10.51",
"lerna": "^3.16.4",
"nodeunit": "^0.11.3",
"nyc": "^14.1.1",
"tslint": "^5.18.0",
"typescript": "^3.5.3"
},
"repository": {
"type": "git",
"url": "https://github.com/aws/jsii.git"
}
"private": true,
"license": "Apache-2.0",
"scripts": {
"bootstrap": "bash scripts/bootstrap.sh",
"build": "bash scripts/build.sh",
"bump": "bash scripts/bump.sh",
"fetch-dotnet-snk": "bash scripts/fetch-dotnet-snk.sh",
"install-local-packages": "node scripts/install-local-packages.js",
"package": "bash scripts/package.sh"
},
"devDependencies": {
"@types/node": "^8.10.51",
"lerna": "^3.16.4",
"nodeunit": "^0.11.3",
"nyc": "^14.1.1",
"tslint": "^5.18.0",
"typescript": "^3.5.3"
},
"repository": {
"type": "git",
"url": "https://github.com/aws/jsii.git"
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion install.sh → scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ lerna bootstrap --reject-cycles --ci

echo "============================================================================================="
echo "installing local links..."
node scripts/install-local-deps.js
npm run install-local-packages
11 changes: 3 additions & 8 deletions build.sh → scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash
set -euo pipefail

if [ ! -d node_modules ]; then
/bin/bash ./install.sh
if [ ! -d ./node_modules ]; then
npm run bootstrap
fi

BUILD_INDICATOR=".BUILD_COMPLETED"
rm -rf $BUILD_INDICATOR

export PATH=node_modules/.bin:$PATH
export PATH=./node_modules/.bin:$PATH

echo "============================================================================================="
echo "building..."
Expand All @@ -17,5 +14,3 @@ lerna run build --stream --sort
echo "============================================================================================="
echo "testing..."
lerna run test --stream

touch $BUILD_INDICATOR
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Installs repo-local dependencies manually, as lerna ignores those...
*/
const { exec, execSync } = require('child_process');
const { removeSync, mkdirpSync, pathExistsSync, symlinkSync, writeJsonSync } = require('fs-extra');
const { dirname, join, relative, resolve } = require('path');
const { removeSync, mkdirpSync, pathExistsSync, readFileSync, symlinkSync, writeJsonSync } = require('fs-extra');
const { basename, dirname, join, resolve } = require('path');

exec('lerna ls --json --all', { shell: true }, (error, stdout) => {
if (error) {
Expand All @@ -25,7 +25,9 @@ exec('lerna ls --json --all', { shell: true }, (error, stdout) => {

function installDeps(location, ...depLists) {
const nodeModules = join(location, 'node_modules');
const lockFile = join(location, 'package-lock.json');

const shrinkWrap = join(location, 'npm-shrinkwrap.json');
const lockFile = pathExistsSync(shrinkWrap) ? shrinkWrap : join(location, 'package-lock.json');

const locks = pathExistsSync(lockFile) && require(lockFile);

Expand All @@ -48,11 +50,11 @@ function installDeps(location, ...depLists) {
});
}
if (process.env.VERBOSE) {
console.log(`Fixing up package-lock.json in ${location}`);
console.log(`Fixing up ${basename(lockFile)} in ${location}`);
}
if (locks) {
sortKeys(locks.dependencies);
writeJsonSync(lockFile, locks, { spaces: '\t' });
writeJsonSync(lockFile, locks, { spaces: findIndent(lockFile) });
} else {
// This is dog slow, hence we're playing funky games elsewhere... but we're not in the business of bootstrapping
// a lock-file from scratch, so if there was none, let npm do it's thing instead of trying to replicate.
Expand All @@ -61,6 +63,19 @@ function installDeps(location, ...depLists) {

}

function findIndent(path) {
if (pathExistsSync(path)) {
const lines = readFileSync(path, { encoding: 'utf-8' }).split('\n');
for (const line of lines) {
const match = line.match(/^(\s+)/)
if (match) {
return match[1];
}
}
}
return 2;
}

/**
* Installs a symlink to a local package, and symlinks any "bin" items into the node_modules/.bin directory
* @param {string} nodeModules the root of the "installing" node_modules directory
Expand Down
File renamed without changes.
File renamed without changes.