Skip to content

Commit

Permalink
fix(rush): add appropriate path-mapping, add sourcemaps for dev (#1869)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwbyrne committed Nov 20, 2019
1 parent 980af2a commit 303caa1
Show file tree
Hide file tree
Showing 22 changed files with 185 additions and 155 deletions.
51 changes: 26 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
aliases:
- &restore-pnpm-store-10
- &restore-yarn-cache-10
keys:
- v7-pnpm-10-{{ .Branch }}-{{ checksum "common/config/rush/pnpm-lock.yaml" }}
- v7-yarn-10-{{ .Branch }}-{{ checksum "common/config/rush/yarn.lock" }}
# Fallback in case checksum fails
- v7-pnpm-10-{{ .Branch }}-
- v7-yarn-10-{{ .Branch }}-

- &save-pnpm-store-10
- &save-yarn-cache-10
paths:
- common/temp/node_modules
- common/temp/pnpm-store
key: v7-pnpm-10-{{ .Branch }}-{{ checksum "common/config/rush/pnpm-lock.yaml" }}
- common/temp/yarn-cache
key: v7-yarn-10-{{ .Branch }}-{{ checksum "common/config/rush/yarn.lock" }}

- &restore-pnpm-store-12
- &restore-yarn-cache-12
keys:
- v7-pnpm-12-{{ .Branch }}-{{ checksum "common/config/rush/pnpm-lock.yaml" }}
- v7-yarn-12-{{ .Branch }}-{{ checksum "common/config/rush/yarn.lock" }}
# Fallback in case checksum fails
- v7-pnpm-12-{{ .Branch }}-
- v7-yarn-12-{{ .Branch }}-

- &save-pnpm-store-12
- &save-yarn-cache-12
paths:
- common/temp/node_modules
- common/temp/pnpm-store
key: v7-pnpm-12-{{ .Branch }}-{{ checksum "common/config/rush/pnpm-lock.yaml" }}
- common/temp/yarn-cache
key: v7-yarn-12-{{ .Branch }}-{{ checksum "common/config/rush/yarn.lock" }}

- &filter-ignore-bors-tmp
branches:
Expand All @@ -36,13 +36,17 @@ aliases:
working_directory: ~/neo-one
steps:
- checkout
- restore-cache: *restore-pnpm-store-12
- restore-cache: *restore-yarn-cache-12
- run: *install
- save-cache: *save-pnpm-store-12
- save-cache: *save-yarn-cache-12
- run:
name: Changelog
command: node common/scripts/install-run-rush.js change -v
when: always
- run:
name: Lint
command: node common/scripts/install-run-rush.js lint -p 8
when: always
- run:
name: Prettier
command: node common/scripts/install-run-rush.js nit
Expand All @@ -52,15 +56,12 @@ aliases:
working_directory: ~/neo-one
steps:
- checkout
- restore-cache: *restore-pnpm-store-10
- restore-cache: *restore-yarn-cache-10
- run: *install
- save-cache: *save-pnpm-store-10
- save-cache: *save-yarn-cache-10
- run:
name: Build
command: node common/scripts/install-run-rush.js rebuild
- run:
name: Lint
command: node common/scripts/install-run-rush.js lint -p 8
- persist_to_workspace:
root: ~/neo-one
paths:
Expand All @@ -74,9 +75,9 @@ aliases:
- checkout
- attach_workspace:
at: ./
- restore-cache: *restore-pnpm-store-10
- restore-cache: *restore-yarn-cache-10
- run: *install
- save-cache: *save-pnpm-store-10
- save-cache: *save-yarn-cache-10
- run:
name: Test
command: node common/scripts/install-run-rush.js test-ci --test-path-pattern '$(circleci tests glob packages/*/src/__tests__/**/*.test.ts)' --coverage
Expand All @@ -99,9 +100,9 @@ aliases:
working_directory: ~/neo-one
steps:
- checkout
- restore-cache: *restore-pnpm-store-12
- restore-cache: *restore-yarn-cache-12
- run: *install
- save-cache: *save-pnpm-store-12
- save-cache: *save-yarn-cache-12
- run:
name: Build
command: node common/scripts/install-run-rush.js rebuild
Expand All @@ -121,9 +122,9 @@ aliases:
- checkout
- attach_workspace:
at: ./
- restore-cache: *restore-pnpm-store-12
- restore-cache: *restore-yarn-cache-12
- run: *install
- save-cache: *save-pnpm-store-12
- save-cache: *save-yarn-cache-12
- run:
name: Test
command: node common/scripts/install-run-rush.js test-ci --test-path-pattern '$(circleci tests glob packages/*/src/__tests__/**/*.test.ts)' --coverage
Expand Down
7 changes: 5 additions & 2 deletions .huskyrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const path = require('path');

const basePath = path.resolve(__dirname, '.git');

module.exports = {
hooks: {
'pre-commit':
'rush check && rush lint:staged -p 16 && rush tsc -p 16 && rush change -v',
'pre-commit': `rush check && rush lint:staged -p 16 && rush build && GIT_DIR=${basePath} rush change -v`,
'post-merge': 'rush install',
'post-rewrite': 'rush install',
'post-checkout': 'rush install',
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"deepscan.enable": true,
"files.associations": {
"[Dd]ockerfile*": "dockerfile",
"docker-compose*": "yaml"
"docker-compose*": "yaml",
"*.d.ts.map": "json"
}
}
6 changes: 6 additions & 0 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,12 @@
"description": "enables cleaning of lib/* and rush/* directories",
"associatedCommands": ["clean"]
},
{
"parameterKind": "flag",
"longName": "--detect-open-handles",
"description": "pass through of jest's detectOpenHandle flag",
"associatedCommands": ["test", "test-ci", "e2e", "e2e-ci"]
},
{
"parameterKind": "string",
"longName": "--test-path-pattern",
Expand Down
4 changes: 2 additions & 2 deletions common/config/rush/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@
cross-env "^6.0.0"
cypress "3.4.1"
cypress-plugin-retries "^1.2.2"
husky "^3.0.9"
husky "^3.1.0"
json "^9.0.6"
lint-staged "^9.4.1"
rxjs-tslint-rules "^4.24.3"
Expand Down Expand Up @@ -9573,7 +9573,7 @@ human-signals@^1.1.1:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==

husky@^3.0.9:
husky@^3.0.9, husky@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-3.1.0.tgz#5faad520ab860582ed94f0c1a77f0f04c90b57c0"
integrity sha512-FJkPoHHB+6s4a+jwPqBudBDvYZsoQW5/HBuMSehC8qDiCe50kpcxeqFoDSlow+9I6wg47YxBoT3WxaURlrDIIQ==
Expand Down
2 changes: 1 addition & 1 deletion deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/neoone/node:1.5
FROM neoonesuite/node:latest
RUN mkdir -p etc/static-html
COPY static/ etc/static-html/
CMD ["--environment.rpc.splashScreen.path=/etc/static-html/", "--environment.rpc.http.host=0.0.0.0"]
2 changes: 1 addition & 1 deletion packages/neo-one-build-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"cypress": "3.4.1",
"cypress-plugin-retries": "^1.2.2",
"json": "^9.0.6",
"husky": "^3.0.9",
"husky": "^3.1.0",
"lint-staged": "^9.4.1",
"rxjs-tslint-rules": "^4.24.3",
"serve": "^11.2.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/neo-one-build-tests/tsconfig.jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"bn.js": ["node_modules/@neo-one/build-tools/types/bn.js.d.ts"],
"@neo-one/*": ["../neo-one-*/src"]
"bn.js": ["node_modules/@neo-one/build-tools/types/bn.js.d.ts"]
}
},
"exclude": [
Expand Down
2 changes: 1 addition & 1 deletion packages/neo-one-build-tools/bin/neo-one-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ require('ts-node').register({
transpileOnly: true,
project: path.resolve(__dirname, '..', 'tsconfig.json'),
});
const linter = require('../src/linters/lint.ts');
const linter = require('../src/lint.ts');

linter.lint();
4 changes: 2 additions & 2 deletions packages/neo-one-build-tools/includes/tsconfig.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"paths": {
"bn.js": ["node_modules/@neo-one/build-tools/types/bn.js.d.ts"]
// "@neo-one/*": ["../neo-one-*/src"]
"bn.js": ["node_modules/@neo-one/build-tools/types/bn.js.d.ts"],
"@neo-one/*": ["../neo-one-*/src"]
}
},
"exclude": ["./node_modules", "./lib", "./src/__data__/contracts/**/*.ts", "./template/**/*.ts?(x)"]
Expand Down
2 changes: 1 addition & 1 deletion packages/neo-one-build-tools/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const compileBinTask = new BuildTask(buildBin);

export const copyDataTask = new BuildTask<undefined>(copyData);

export const packTask = new BuildTask<undefined>(pack, ['lib/**']);
export const packTask = new BuildTask<undefined>(pack, ['lib/**', '!lib/**/*.map']);

export const packBinTask = new BuildTask<undefined>(packBin);

Expand Down
44 changes: 21 additions & 23 deletions packages/neo-one-build-tools/src/builds/buildBin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ import gulp from 'gulp';
import gulpBanner from 'gulp-banner';
import gulpPlumber from 'gulp-plumber';
import gulpRename from 'gulp-rename';
// import gulpSourcemaps from 'gulp-sourcemaps';
import gulpSourcemaps from 'gulp-sourcemaps';
import ts from 'gulp-typescript';
import path from 'path';
import typescript from 'typescript';
import { Format } from '../formats';
import { flattenBin, gulpReplaceBin, gulpReplaceModule, replaceCmd } from '../utils';

const gulpBin = (format: Format, binPath: string) =>
gulpReplaceModule(format, gulp.src(binPath)).pipe(
gulpRename((parsedPath) => {
if (parsedPath.dirname === undefined) {
throw new Error('error creating bin');
}
// tslint:disable-next-line: no-object-mutation
parsedPath.dirname = `${parsedPath.dirname.slice(0, -'/src/bin'.length)}/bin`;
}),
);
gulpReplaceModule(format, gulp.src(binPath))
.pipe(gulpSourcemaps.init())
.pipe(
gulpRename((parsedPath) => {
if (parsedPath.dirname === undefined) {
throw new Error('error creating bin');
}
// tslint:disable-next-line: no-object-mutation
parsedPath.dirname = `${parsedPath.dirname.slice(0, -'/src/bin'.length)}/bin`;
}),
);

const binBanner = `#!/usr/bin/env node
require('source-map-support').install({ handleUncaughtExceptions: false, environment: 'node' });
Expand All @@ -33,19 +35,15 @@ const compileBin = (format: Format, binGlob: string) => {
declaration: false,
});

return (
gulpBin(format, binGlob)
// .pipe(gulpSourcemaps.init())
.pipe(gulpPlumber())
.pipe(binProject())
.pipe(gulpBanner(binBanner))
// .pipe(gulpSourcemaps.mapSources(mapSources))
// .pipe(gulpSourcemaps.write())
.pipe(replaceCmd)
.pipe(flattenBin)
.pipe(gulpReplaceBin())
.pipe(gulp.dest('lib'))
);
return gulpBin(format, binGlob)
.pipe(gulpPlumber())
.pipe(binProject())
.pipe(gulpBanner(binBanner))
.pipe(replaceCmd)
.pipe(flattenBin)
.pipe(gulpReplaceBin())
.pipe(gulpSourcemaps.write('.', { includeContent: false, sourceRoot: '../src' }))
.pipe(gulp.dest('lib'));
};

export const buildBin = (format: Format) => () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/neo-one-build-tools/src/builds/buildTypescript.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// tslint:disable: no-any match-default-export-name
import gulp from 'gulp';
import gulpPlumber from 'gulp-plumber';
// import gulpSourcemaps from 'gulp-sourcemaps';
import gulpSourcemaps from 'gulp-sourcemaps';
import ts from 'gulp-typescript';
// import path from 'path';
import typescript from 'typescript';
import { Format } from '../formats';
import {
Expand All @@ -15,7 +14,6 @@ import {
replaceInternalSources,
replaceRXJSImport,
replaceStatic,
// transformPackage,
} from '../utils';

export interface CompileTypescriptOptions {
Expand All @@ -40,13 +38,15 @@ export const buildTypescript = (format: Format, pkgName?: string) => (
gulp
.src(glob)
.pipe(gulpPlumber())
.pipe(gulpSourcemaps.init())
.pipe(project())
.pipe(replaceRXJSImport(format))
.pipe(replaceInternalSources)
.pipe(replaceBNTypeImport)
.pipe(replaceBNImport)
.pipe(replaceStatic)
.pipe(flattenSource)
.pipe(gulpSourcemaps.write('.', { includeContent: false, sourceRoot: '../src' }))
.pipe(filterJS(isToolsPackage)),
).pipe(gulp.dest('lib'));
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const argv = yargs
.default('pattern', 'src/**/*.ts?(x)').argv;

const CWD = process.cwd();
const APP_ROOT_DIR = path.resolve(__dirname, '..', '..', '..', '..');
const APP_ROOT_DIR = path.resolve(__dirname, '..', '..', '..');
const TSLINT_CONFIG = path.resolve(APP_ROOT_DIR, 'tslint.json');

export const writeReport = (report: LintResult) => {
Expand Down
1 change: 0 additions & 1 deletion packages/neo-one-build-tools/src/linters/index.ts

This file was deleted.

11 changes: 9 additions & 2 deletions packages/neo-one-build-tools/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { argv } = yargs

const APP_ROOT_DIR = path.resolve(__dirname, '..', '..', '..');
const rushJSON = fs.readJsonSync(path.resolve(APP_ROOT_DIR, 'rush.json'));
const PUBLISH_SCRIPT = path.resolve(__dirname, '..', 'scripts', 'try-publish');
const PUBLISH_SCRIPT = path.resolve(APP_ROOT_DIR, 'scripts', 'try-publish');

// tslint:disable: no-any
const packages: readonly string[] = rushJSON.projects
Expand All @@ -23,8 +23,15 @@ const packages: readonly string[] = rushJSON.projects
// tslint:enable no-any

const publishPackage = async (format: Format, pkgName: string) => {
const packageDist = path.resolve(APP_ROOT_DIR, 'dist', format.dist, getName(format, pkgName));
const packageExists = await fs.pathExists(packageDist);

if (!packageExists) {
throw new Error(`no publishable package found at ${packageDist}`);
}

await execa(PUBLISH_SCRIPT, {
cwd: path.resolve(APP_ROOT_DIR, 'dist', format.dist, getName(format, pkgName)),
cwd: packageDist,
stdio: ['ignore', 'inherit', 'inherit'],
});
};
Expand Down
2 changes: 0 additions & 2 deletions packages/neo-one-build-tools/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// tslint:disable:match-default-export-name no-any
import fs from 'fs-extra';
import gulpFilter from 'gulp-filter';
// @ts-ignore
// import jsonTransform from 'gulp-json-transform';
import gulpIf from 'gulp-if';
import gulpRename from 'gulp-rename';
import gulpReplace from 'gulp-replace';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const createFormatOptionLabel = (isMulti?: boolean) => (
<Box>{option.address}</Box>
</>
)}
{/* tslint:disable-next-line no-useless-cast */}
{((option as any).balances === undefined ? [] : (option as any).balances).map(
([name, value]: [string, BigNumber]) => (
// @ts-ignore
Expand Down
19 changes: 0 additions & 19 deletions packages/neo-one-node/.npmignore

This file was deleted.

Loading

0 comments on commit 303caa1

Please sign in to comment.