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 98d8cb9
Show file tree
Hide file tree
Showing 25 changed files with 202 additions and 312 deletions.
67 changes: 34 additions & 33 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 @@ -87,10 +88,10 @@ aliases:
- run:
name: E2E
command: node common/scripts/install-run-rush.js e2e-ci --test-path-pattern '$(circleci tests glob packages/*/src/__e2e__/**/*.test.ts)'
# - run:
# name: Upload E2E Test Coverage
# command: node common/scripts/install-run-rush.js upload-coverage -F e2e
# when: always
- run:
name: Upload E2E Test Coverage
command: node common/scripts/install-run-rush.js upload-coverage -F e2e
when: always
- store_test_results:
path: reports
parallelism: 2
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 All @@ -134,10 +135,10 @@ aliases:
- run:
name: E2E
command: node common/scripts/install-run-rush.js e2e-ci --test-path-pattern '$(circleci tests glob packages/*/src/__e2e__/**/*.test.ts)'
# - run:
# name: Upload E2E Test Coverage
# command: node common/scripts/install-run-rush.js upload-coverage -F e2e
# when: always
- run:
name: Upload E2E Test Coverage
command: node common/scripts/install-run-rush.js upload-coverage -F e2e
when: always
- store_test_results:
path: reports
parallelism: 2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ jobs:
- name: Checkout Code
uses: actions/checkout@94d077c24971944d312dd9197c1bdfba62b39878
- name: Install Node
run: brew update-reset && brew update && export PATH="/usr/local/bin:$PATH" && brew unlink node@6 && brew install node
run: brew update-reset && brew update && && brew unlink node@12 && brew install node@10 && brew link node@10
- name: Install Chrome
run: brew cask install google-chrome
- name: Rush Install
run: node/common/scripts/install-run-rush.js install
run: node common/scripts/install-run-rush.js install
- name: Rush Rebuild
run: node/common/scripts/install-run-rush.js rebuild
run: node common/scripts/install-run-rush.js rebuild
- name: Rush Link Root
run: node/common/scripts/install-run-rush.js link-root
run: node common/scripts/install-run-rush.js link-root
- name: Run Cypress Express Test
run: node/common/scripts/install-run-rush.js test-cypress --express
run: node common/scripts/install-run-rush.js test-cypress --express
- name: Rush Unlink Root
run: node/common/scripts/install-run-rush.js unlink-root
run: node common/scripts/install-run-rush.js unlink-root
- name: Store Cypress Screenshots
if: failure()
continue-on-error: true
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
5 changes: 2 additions & 3 deletions packages/neo-one-build-tools-web/src/webpack/plugin/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ export const node = () => ({
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />,
<meta name="theme-color" content="#ffffff" />,
<meta name="application-name" content="NEO•ONE" />,
// @ts-ignore
<meta charset="utf-8" />,
<meta http-equiv="X-UA-Compatible" content="IE=edge" />,
<meta charSet="utf-8" />,
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />,
<meta name="viewport" content="width=device-width, initial-scale=1" />,
],
});
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'));
};
Loading

0 comments on commit 98d8cb9

Please sign in to comment.