From dca1884f7524effc805d618d46c0df901181fc95 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 15:23:39 -0700 Subject: [PATCH 01/12] Set up a small set of packages that we can build --- apps/my-app/package.json | 17 +++++++++++++ apps/my-app/src/start.ts | 4 ++++ apps/my-app/tsconfig.json | 36 ++++++++++++++++++++++++++++ libraries/my-controls/package.json | 16 +++++++++++++ libraries/my-controls/src/MyClass.ts | 6 +++++ libraries/my-controls/src/index.ts | 1 + libraries/my-controls/tsconfig.json | 36 ++++++++++++++++++++++++++++ tools/my-toolchain/package.json | 21 ++++++++++++++++ tools/my-toolchain/src/start.ts | 10 ++++++++ tools/my-toolchain/tsconfig.json | 34 ++++++++++++++++++++++++++ 10 files changed, 181 insertions(+) create mode 100644 apps/my-app/package.json create mode 100644 apps/my-app/src/start.ts create mode 100644 apps/my-app/tsconfig.json create mode 100644 libraries/my-controls/package.json create mode 100644 libraries/my-controls/src/MyClass.ts create mode 100644 libraries/my-controls/src/index.ts create mode 100644 libraries/my-controls/tsconfig.json create mode 100644 tools/my-toolchain/package.json create mode 100644 tools/my-toolchain/src/start.ts create mode 100644 tools/my-toolchain/tsconfig.json diff --git a/apps/my-app/package.json b/apps/my-app/package.json new file mode 100644 index 00000000..b5425559 --- /dev/null +++ b/apps/my-app/package.json @@ -0,0 +1,17 @@ +{ + "name": "my-app", + "version": "1.0.0", + "description": "An example application that consumes the my-controls library", + "license": "MIT", + "scripts": { + "build": "node_modules/.bin/my-build" + }, + "dependencies": { + "my-controls": "^1.0.0", + "whatwg-fetch": "^3.0.0" + }, + "devDependencies": { + "my-toolchain": "^1.0.0", + "typescript": "^3.0.3" + } +} diff --git a/apps/my-app/src/start.ts b/apps/my-app/src/start.ts new file mode 100644 index 00000000..36b13048 --- /dev/null +++ b/apps/my-app/src/start.ts @@ -0,0 +1,4 @@ +import { MyClass } from 'my-controls'; + +let myClass: MyClass = new MyClass(); +myClass.doSomething(); diff --git a/apps/my-app/tsconfig.json b/apps/my-app/tsconfig.json new file mode 100644 index 00000000..073e2559 --- /dev/null +++ b/apps/my-app/tsconfig.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "compilerOptions": { + "outDir": "lib", + + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "declaration": true, + "sourceMap": true, + "inlineSources": true, + "experimentalDecorators": true, + "strictNullChecks": true, + "types": [ + ], + + "module": "esnext", + "moduleResolution": "node", + "target": "es5", + "lib": [ + "es5", + "scripthost", + "es2015.collection", + "es2015.promise", + "es2015.iterable", + "dom" + ] + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "node_modules", + "lib" + ] +} diff --git a/libraries/my-controls/package.json b/libraries/my-controls/package.json new file mode 100644 index 00000000..0de69b90 --- /dev/null +++ b/libraries/my-controls/package.json @@ -0,0 +1,16 @@ +{ + "name": "my-controls", + "version": "1.0.0", + "description": "An example library project", + "license": "MIT", + "main": "lib/index.js", + "typings": "lib/index.d.ts", + "scripts": { + "build": "node_modules/.bin/my-build" + }, + "dependencies": {}, + "devDependencies": { + "my-toolchain": "^1.0.0", + "typescript": "^3.0.3" + } +} diff --git a/libraries/my-controls/src/MyClass.ts b/libraries/my-controls/src/MyClass.ts new file mode 100644 index 00000000..daf4fb06 --- /dev/null +++ b/libraries/my-controls/src/MyClass.ts @@ -0,0 +1,6 @@ + +export class MyClass { + public doSomething(): void { + console.log('Hello, world!'); + } +} diff --git a/libraries/my-controls/src/index.ts b/libraries/my-controls/src/index.ts new file mode 100644 index 00000000..9984c386 --- /dev/null +++ b/libraries/my-controls/src/index.ts @@ -0,0 +1 @@ +export { MyClass } from './MyClass'; diff --git a/libraries/my-controls/tsconfig.json b/libraries/my-controls/tsconfig.json new file mode 100644 index 00000000..073e2559 --- /dev/null +++ b/libraries/my-controls/tsconfig.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "compilerOptions": { + "outDir": "lib", + + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "declaration": true, + "sourceMap": true, + "inlineSources": true, + "experimentalDecorators": true, + "strictNullChecks": true, + "types": [ + ], + + "module": "esnext", + "moduleResolution": "node", + "target": "es5", + "lib": [ + "es5", + "scripthost", + "es2015.collection", + "es2015.promise", + "es2015.iterable", + "dom" + ] + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "node_modules", + "lib" + ] +} diff --git a/tools/my-toolchain/package.json b/tools/my-toolchain/package.json new file mode 100644 index 00000000..fa7b7ba9 --- /dev/null +++ b/tools/my-toolchain/package.json @@ -0,0 +1,21 @@ +{ + "name": "my-toolchain", + "version": "1.0.0", + "description": "An example toolchain used to build projects in this repo", + "license": "MIT", + "bin": { + "my-build": "lib/start.js" + }, + "scripts": { + "build": "rimraf ./lib/ && tsc" + }, + "dependencies": { + "@types/colors": "^1.2.1", + "colors": "^1.3.2" + }, + "devDependencies": { + "@types/node": "^10.9.4", + "rimraf": "^2.6.2", + "typescript": "^3.0.3" + } +} diff --git a/tools/my-toolchain/src/start.ts b/tools/my-toolchain/src/start.ts new file mode 100644 index 00000000..699384f1 --- /dev/null +++ b/tools/my-toolchain/src/start.ts @@ -0,0 +1,10 @@ +#!/usr/bin/env node + +import * as colors from 'colors'; +import * as child_process from 'child_process'; + +console.log('Invoking my-toolchain...'); + +child_process.execSync('tsc', { stdio: 'inherit' }); + +console.log(colors.green('Success!')); diff --git a/tools/my-toolchain/tsconfig.json b/tools/my-toolchain/tsconfig.json new file mode 100644 index 00000000..52f07f22 --- /dev/null +++ b/tools/my-toolchain/tsconfig.json @@ -0,0 +1,34 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "compilerOptions": { + "outDir": "lib", + + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "declaration": true, + "sourceMap": true, + "inlineSources": true, + "experimentalDecorators": true, + "strictNullChecks": true, + "types": [ + "node" + ], + + "module": "commonjs", + "target": "es6", + "lib": [ + "es5", + "es2015.collection", + "es2015.iterable", + "es2015.promise" + ] + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "node_modules", + "lib" + ] +} From 4b9a4c086165b624e02132ac1f1d9986ebfa6679 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 15:24:29 -0700 Subject: [PATCH 02/12] Set up .gitignore and .gitattributes for repo --- .gitattributes | 68 ++++++++++++++++++++++++++ .gitignore | 126 ++++++++++++++++++++++++++----------------------- 2 files changed, 134 insertions(+), 60 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..02d01126 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,68 @@ +# Prevent Git to auto detect text files and perform LF normalization. +* -text + +# The item with `binary` is treated as binary file. +# The item with `eol=lf` is converted to LF on checkin, back to LF on checkout. +# The item with `eol=crlf` is converted to LF on checkin, back to CRLF on checkout. + +# To get full extension list in the repo, remove the node_modules folder and run the following PowerShell cmdlet. +# PS> Get-ChildItem . -Recurse | Where-Object { -not $_.PSIsContainer } | ForEach-Object { $_.Extension.ToLower() } | Sort-Object | Get-Unique + +# If new extensions are added, please refresh the repo with the following commands. +# Reference: https://git-scm.com/docs/gitattributes +# > rm .git/index # Remove the index to force Git to +# > git reset # re-scan the working directory +# > git status # Show files that will be normalized +# > git add -u +# > git add .gitattributes +# > git commit -m "Apply end-of-line normalization based on updated .gitattributes file" + +*.aspx text eol=crlf +*.bowerrc text eol=lf +*.cmd text eol=crlf +*.command text eol=lf +*.config text eol=crlf +*.cs text eol=crlf +*.csproj text eol=crlf +*.css text eol=crlf +*.dll binary +*.editorconfig text eol=lf +*.eot binary +*.example text eol=crlf +*.exe binary +*.gif binary +*.gitattributes text eol=lf +*.gitignore text eol=lf +*.gitmodules text eol=lf +*.html text eol=crlf +*.ico binary +*.jpg binary +*.js text eol=crlf +*.json text eol=crlf +*.less text eol=crlf +*.map text eol=lf +*.md text eol=crlf +*.npmignore text eol=lf +*.png binary +*.ps1 text eol=crlf +*.rels text eol=crlf +*.resx text eol=crlf +*.scss text eol=crlf +*.sln text eol=crlf +*.svg text elf=lf +*.ts text eol=crlf +*.tsx text eol=crlf +*.ttf binary +*.woff binary +*.wsp binary +*.xml text eol=crlf + +# NPM "bin" scripts MUST have LF, or else the executable fails to run on Mac. +# This fnmatch expression only matches files in a "bin" folder and without +# a period in the filename. +/*/*/bin/+([!.]) -text + +# Don't allow people to merge changes to these generated files, because the result +# may be invalid. You need to run "rush generate" again. +shrinkwrap.yaml merge=binary +npm-shrinkwrap.json merge=binary diff --git a/.gitignore b/.gitignore index ad46b308..1f8b26db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,61 +1,67 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) +# Windows OS Files +$RECYCLE.BIN/ +Desktop.ini +Thumbs.db +ehthumbs.db + +# Mac OSX Files +.AppleDouble +.DS_Store +.LSOverride +.Spotlight-V100 +.Trashes +._* + +# Package files +app +app-min bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# next.js build output -.next +coverage +local +dist +jspm_packages +lib +lib-amd +lib-es6 +node_modules +npm-debug.log +npminstall-log.txt +temp + +# Rush files +**/*.build.error.log +**/*.build.log +/common/apiDocs/json/** +/common/last-install.flag +/common/last-install.log +/common/local-npm +/common/local-npm/** +/common/local-rush +/common/local-rush/** +/common/npm-cache +/common/npm-cache/** +/common/npm-local +/common/npm-local/** +/common/npm-tmp +/common/npm-tmp/** +/common/rush-link.json +/common/rush-recycler +package-deps.json + +# IDE files +*.bak +*.csproj.user +*.sublime-project +*.sublime-workspace +*.suo +*.userosscache +.idea +.vs/ +/.settings/ +bin/ + +# Ignore VS Code personal settings, but keep a root-level setting +/*/**/.vscode/ + +# Build artifacts +**/*.scss.ts From 6d3c78e3c24af1d9f79afabf8fbf45953ef94400 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 15:24:48 -0700 Subject: [PATCH 03/12] Update README.md and add a basic rush.json --- README.md | 5 +++++ common/config/rush/.npmrc | 2 ++ rush.json | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 common/config/rush/.npmrc create mode 100644 rush.json diff --git a/README.md b/README.md index 72f1506a..a2c7b6ea 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +# Example Rush Monorepo + +This template is part of the documentation of the [Rush](https://rushjs.io/) tool. +It contains templates for all the Rush configuration files, and a simple setup that +builds two empty projects. # Contributing diff --git a/common/config/rush/.npmrc b/common/config/rush/.npmrc new file mode 100644 index 00000000..f6a02f2d --- /dev/null +++ b/common/config/rush/.npmrc @@ -0,0 +1,2 @@ +registry=https://registry.npmjs.org/ +always-auth=false diff --git a/rush.json b/rush.json new file mode 100644 index 00000000..5d7ff5ba --- /dev/null +++ b/rush.json @@ -0,0 +1,40 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", + + "rushVersion": "5.1.0", + "pnpmVersion": "2.15.1", + "nodeSupportedVersionRange": ">=6.9.0 <7.0.0 || >=8.9.4 <9.0.0", + + "projectFolderMinDepth": 2, + + "approvedPackagesPolicy": { + "reviewCategories": [ "main", "tools", "prototypes" ], + "ignoredNpmScopes": [ "@types" ] + }, + + "gitPolicy": { + // Require GitHub scrubbed e-mails + "allowedEmailRegExps": [ + "[^@]+@users\\.noreply\\.github\\.com" + ], + "sampleEmail": "mrexample@users.noreply.github.com" + }, + + "projects": [ + { + "packageName": "my-app", + "projectFolder": "apps/my-app", + "reviewCategory": "main" + }, + { + "packageName": "my-controls", + "projectFolder": "libraries/my-controls", + "reviewCategory": "main" + }, + { + "packageName": "my-toolchain", + "projectFolder": "tools/my-toolchain", + "reviewCategory": "tools" + } + ] +} From a1ee701ce7c6117a93e2bfe6b903761c4a84f0c3 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 15:24:59 -0700 Subject: [PATCH 04/12] Run "rush update" --- .../rush/browser-approved-packages.json | 10 + .../rush/nonbrowser-approved-packages.json | 26 ++ common/config/rush/shrinkwrap.yaml | 154 +++++++ common/scripts/install-run-rush.js | 51 +++ common/scripts/install-run.js | 397 ++++++++++++++++++ 5 files changed, 638 insertions(+) create mode 100644 common/config/rush/browser-approved-packages.json create mode 100644 common/config/rush/nonbrowser-approved-packages.json create mode 100644 common/config/rush/shrinkwrap.yaml create mode 100644 common/scripts/install-run-rush.js create mode 100644 common/scripts/install-run.js diff --git a/common/config/rush/browser-approved-packages.json b/common/config/rush/browser-approved-packages.json new file mode 100644 index 00000000..8afc821f --- /dev/null +++ b/common/config/rush/browser-approved-packages.json @@ -0,0 +1,10 @@ +// DO NOT ADD COMMENTS IN THIS FILE. They will be lost when the Rush tool resaves it. +{ + "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/approved-packages.schema.json", + "packages": [ + { + "name": "whatwg-fetch", + "allowedCategories": [ "main" ] + } + ] +} diff --git a/common/config/rush/nonbrowser-approved-packages.json b/common/config/rush/nonbrowser-approved-packages.json new file mode 100644 index 00000000..824a1a72 --- /dev/null +++ b/common/config/rush/nonbrowser-approved-packages.json @@ -0,0 +1,26 @@ +// DO NOT ADD COMMENTS IN THIS FILE. They will be lost when the Rush tool resaves it. +{ + "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/approved-packages.schema.json", + "packages": [ + { + "name": "colors", + "allowedCategories": [ "tools" ] + }, + { + "name": "my-controls", + "allowedCategories": [ "main" ] + }, + { + "name": "my-toolchain", + "allowedCategories": [ "main" ] + }, + { + "name": "rimraf", + "allowedCategories": [ "tools" ] + }, + { + "name": "typescript", + "allowedCategories": [ "main", "tools" ] + } + ] +} diff --git a/common/config/rush/shrinkwrap.yaml b/common/config/rush/shrinkwrap.yaml new file mode 100644 index 00000000..cd205260 --- /dev/null +++ b/common/config/rush/shrinkwrap.yaml @@ -0,0 +1,154 @@ +dependencies: + '@rush-temp/my-app': 'file:projects/my-app.tgz' + '@rush-temp/my-controls': 'file:projects/my-controls.tgz' + '@rush-temp/my-toolchain': 'file:projects/my-toolchain.tgz' + '@types/colors': 1.2.1 + '@types/node': 10.9.4 + colors: 1.3.2 + rimraf: 2.6.2 + typescript: 3.0.3 + whatwg-fetch: 3.0.0 +packages: + /@types/colors/1.2.1: + dependencies: + colors: 1.3.2 + deprecated: 'This is a stub types definition. colors provides its own type definitions, so you don''t need this installed.' + dev: false + resolution: + integrity: sha512-7jNkpfN2lVO07nJ1RWzyMnNhH/I5N9iWuMPx9pedptxJ4MODf8rRV0lbJi6RakQ4sKQk231Fw4e2W9n3D7gZ3w== + /@types/node/10.9.4: + dev: false + resolution: + integrity: sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw== + /balanced-match/1.0.0: + dev: false + resolution: + integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + /brace-expansion/1.1.11: + dependencies: + balanced-match: 1.0.0 + concat-map: 0.0.1 + dev: false + resolution: + integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + /colors/1.3.2: + dev: false + engines: + node: '>=0.1.90' + resolution: + integrity: sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ== + /concat-map/0.0.1: + dev: false + resolution: + integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + /fs.realpath/1.0.0: + dev: false + resolution: + integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + /glob/7.1.3: + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.3 + minimatch: 3.0.4 + once: 1.4.0 + path-is-absolute: 1.0.1 + dev: false + resolution: + integrity: sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== + /inflight/1.0.6: + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + dev: false + resolution: + integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + /inherits/2.0.3: + dev: false + resolution: + integrity: sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + /minimatch/3.0.4: + dependencies: + brace-expansion: 1.1.11 + dev: false + resolution: + integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + /once/1.4.0: + dependencies: + wrappy: 1.0.2 + dev: false + resolution: + integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + /path-is-absolute/1.0.1: + dev: false + engines: + node: '>=0.10.0' + resolution: + integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + /rimraf/2.6.2: + dependencies: + glob: 7.1.3 + dev: false + hasBin: true + resolution: + integrity: sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w== + /typescript/3.0.3: + dev: false + engines: + node: '>=4.2.0' + hasBin: true + resolution: + integrity: sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg== + /whatwg-fetch/3.0.0: + dev: false + resolution: + integrity: sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q== + /wrappy/1.0.2: + dev: false + resolution: + integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + 'file:projects/my-app.tgz': + dependencies: + typescript: 3.0.3 + whatwg-fetch: 3.0.0 + dev: false + name: '@rush-temp/my-app' + resolution: + integrity: sha512-YThRXWcn2MrdOxASWIYh2UP6tAxJjLKXAZ/Bl6A9RBZ3cM0qhvglIkrveW8LGOqt9PQM8Z8578DAbWNKfydrIw== + tarball: 'file:projects/my-app.tgz' + version: 0.0.0 + 'file:projects/my-controls.tgz': + dependencies: + typescript: 3.0.3 + dev: false + name: '@rush-temp/my-controls' + resolution: + integrity: sha512-oHXOZCwlbGEILYNWY1vV0/W/Y9oPXB7r6QoLVZdUv/TZ20brYDtZ9/WIzqjN1YNUQRJpmtyyLxp/NAhM8tphBg== + tarball: 'file:projects/my-controls.tgz' + version: 0.0.0 + 'file:projects/my-toolchain.tgz': + dependencies: + '@types/colors': 1.2.1 + '@types/node': 10.9.4 + colors: 1.3.2 + rimraf: 2.6.2 + typescript: 3.0.3 + dev: false + name: '@rush-temp/my-toolchain' + resolution: + integrity: sha512-OGtNAqgdxHzze+shuzbWwyq0Nm97Q2UmDy3kgo3ib88nfA5bfE077ZlV/m+djVmKLMmlEYOGViBzFrQMi/JmSA== + tarball: 'file:projects/my-toolchain.tgz' + version: 0.0.0 +registry: 'https://registry.npmjs.org/' +shrinkwrapMinorVersion: 9 +shrinkwrapVersion: 3 +specifiers: + '@rush-temp/my-app': 'file:./projects/my-app.tgz' + '@rush-temp/my-controls': 'file:./projects/my-controls.tgz' + '@rush-temp/my-toolchain': 'file:./projects/my-toolchain.tgz' + '@types/colors': ^1.2.1 + '@types/node': ^10.9.4 + colors: ^1.3.2 + rimraf: ^2.6.2 + typescript: ^3.0.3 + whatwg-fetch: ^3.0.0 diff --git a/common/scripts/install-run-rush.js b/common/scripts/install-run-rush.js new file mode 100644 index 00000000..51bdbbb2 --- /dev/null +++ b/common/scripts/install-run-rush.js @@ -0,0 +1,51 @@ +"use strict"; +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for license information. +Object.defineProperty(exports, "__esModule", { value: true }); +// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED. +// +// This script is intended for usage in an automated build environment where the Rush command may not have +// been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush +// specified in the rush.json configuration file (if not already installed), and then pass a command-line to it. +// An example usage would be: +// +// node common/scripts/install-run-rush.js install +// +// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +const path = require("path"); +const fs = require("fs"); +const install_run_1 = require("./install-run"); +const PACKAGE_NAME = '@microsoft/rush'; +function getRushVersion() { + const rushJsonFolder = install_run_1.findRushJsonFolder(); + const rushJsonPath = path.join(rushJsonFolder, install_run_1.RUSH_JSON_FILENAME); + try { + const rushJsonContents = fs.readFileSync(rushJsonPath, 'utf-8'); + // Use a regular expression to parse out the rushVersion value because rush.json supports comments, + // but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script. + const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/); + return rushJsonMatches[1]; + } + catch (e) { + throw new Error(`Unable to determine the required version of Rush from rush.json (${rushJsonFolder}). ` + + 'The \'rushVersion\' field is either not assigned in rush.json or was specified ' + + 'using an unexpected syntax.'); + } +} +function run() { + const [nodePath, /* Ex: /bin/node */ // tslint:disable-line:no-unused-variable + scriptPath, /* /repo/common/scripts/install-run-rush.js */ // tslint:disable-line:no-unused-variable + ...packageBinArgs /* [build, --to, myproject] */] = process.argv; + if (process.argv.length < 3) { + console.log('Usage: install-run-rush.js [args...]'); + console.log('Example: install-run-rush.js build --to myproject'); + process.exit(1); + } + install_run_1.runWithErrorAndStatusCode(() => { + const version = getRushVersion(); + console.log(`The rush.json configuration requests Rush version ${version}`); + return install_run_1.installAndRun(PACKAGE_NAME, version, 'rush', packageBinArgs); + }); +} +run(); +//# sourceMappingURL=install-run-rush.js.map \ No newline at end of file diff --git a/common/scripts/install-run.js b/common/scripts/install-run.js new file mode 100644 index 00000000..08539132 --- /dev/null +++ b/common/scripts/install-run.js @@ -0,0 +1,397 @@ +"use strict"; +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for license information. +Object.defineProperty(exports, "__esModule", { value: true }); +// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED. +// +// This script is intended for usage in an automated build environment where a Node tool may not have +// been preinstalled, or may have an unpredictable version. This script will automatically install the specified +// version of the specified tool (if not already installed), and then pass a command-line to it. +// An example usage would be: +// +// node common/scripts/install-run.js rimraf@2.6.2 rimraf -f project1/lib +// +// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +const childProcess = require("child_process"); +const fs = require("fs"); +const os = require("os"); +const path = require("path"); +exports.RUSH_JSON_FILENAME = 'rush.json'; +const INSTALLED_FLAG_FILENAME = 'installed.flag'; +const NODE_MODULES_FOLDER_NAME = 'node_modules'; +const PACKAGE_JSON_FILENAME = 'package.json'; +/** + * Parse a package specifier (in the form of name\@version) into name and version parts. + */ +function parsePackageSpecifier(rawPackageSpecifier) { + rawPackageSpecifier = (rawPackageSpecifier || '').trim(); + const separatorIndex = rawPackageSpecifier.lastIndexOf('@'); + let name; + let version = undefined; + if (separatorIndex === 0) { + // The specifier starts with a scope and doesn't have a version specified + name = rawPackageSpecifier; + } + else if (separatorIndex === -1) { + // The specifier doesn't have a version + name = rawPackageSpecifier; + } + else { + name = rawPackageSpecifier.substring(0, separatorIndex); + version = rawPackageSpecifier.substring(separatorIndex + 1); + } + if (!name) { + throw new Error(`Invalid package specifier: ${rawPackageSpecifier}`); + } + return { name, version }; +} +/** + * Resolve a package specifier to a static version + */ +function resolvePackageVersion(rushCommonFolder, { name, version }) { + if (!version) { + version = '*'; // If no version is specified, use the latest version + } + if (version.match(/^[a-zA-Z0-9\-\+\.]+$/)) { + // If the version contains only characters that we recognize to be used in static version specifiers, + // pass the version through + return version; + } + else { + // version resolves to + try { + const rushTempFolder = ensureAndJoinPath(rushCommonFolder, 'temp'); + const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush'); + syncNpmrc(sourceNpmrcFolder, rushTempFolder); + const npmPath = getNpmPath(); + // This returns something that looks like: + // @microsoft/rush@3.0.0 '3.0.0' + // @microsoft/rush@3.0.1 '3.0.1' + // ... + // @microsoft/rush@3.0.20 '3.0.20' + // + const npmVersionSpawnResult = childProcess.spawnSync(npmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier'], { + cwd: rushTempFolder, + stdio: [] + }); + if (npmVersionSpawnResult.status !== 0) { + throw new Error(`"npm view" returned error code ${npmVersionSpawnResult.status}`); + } + const npmViewVersionOutput = npmVersionSpawnResult.stdout.toString(); + const versionLines = npmViewVersionOutput.split('\n').filter((line) => !!line); + const latestVersion = versionLines[versionLines.length - 1]; + if (!latestVersion) { + throw new Error('No versions found for the specified version range.'); + } + const versionMatches = latestVersion.match(/^.+\s\'(.+)\'$/); + if (!versionMatches) { + throw new Error(`Invalid npm output ${latestVersion}`); + } + return versionMatches[1]; + } + catch (e) { + throw new Error(`Unable to resolve version ${version} of package ${name}: ${e}`); + } + } +} +let _npmPath = undefined; +/** + * Get the absolute path to the npm executable + */ +function getNpmPath() { + if (!_npmPath) { + try { + if (os.platform() === 'win32') { + // We're on Windows + const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString(); + const lines = whereOutput.split(os.EOL).filter((line) => !!line); + // take the last result, we are looking for a .cmd command + // see https://github.com/Microsoft/web-build-tools/issues/759 + _npmPath = lines[lines.length - 1]; + } + else { + // We aren't on Windows - assume we're on *NIX or Darwin + _npmPath = childProcess.execSync('which npm', { stdio: [] }).toString(); + } + } + catch (e) { + throw new Error(`Unable to determine the path to the NPM tool: ${e}`); + } + _npmPath = _npmPath.trim(); + if (!fs.existsSync(_npmPath)) { + throw new Error('The NPM executable does not exist'); + } + } + return _npmPath; +} +exports.getNpmPath = getNpmPath; +let _rushJsonFolder; +/** + * Find the absolute path to the folder containing rush.json + */ +function findRushJsonFolder() { + if (!_rushJsonFolder) { + let basePath = __dirname; + let tempPath = __dirname; + do { + const testRushJsonPath = path.join(basePath, exports.RUSH_JSON_FILENAME); + if (fs.existsSync(testRushJsonPath)) { + _rushJsonFolder = basePath; + break; + } + else { + basePath = tempPath; + } + } while (basePath !== (tempPath = path.dirname(basePath))); // Exit the loop when we hit the disk root + if (!_rushJsonFolder) { + throw new Error('Unable to find rush.json.'); + } + } + return _rushJsonFolder; +} +exports.findRushJsonFolder = findRushJsonFolder; +/** + * Create missing directories under the specified base directory, and return the resolved directory. + * + * Does not support "." or ".." path segments. + * Assumes the baseFolder exists. + */ +function ensureAndJoinPath(baseFolder, ...pathSegments) { + let joinedPath = baseFolder; + try { + for (let pathSegment of pathSegments) { + pathSegment = pathSegment.replace(/[\\\/]/g, '+'); + joinedPath = path.join(joinedPath, pathSegment); + if (!fs.existsSync(joinedPath)) { + fs.mkdirSync(joinedPath); + } + } + } + catch (e) { + throw new Error(`Error building local installation folder (${path.join(baseFolder, ...pathSegments)}): ${e}`); + } + return joinedPath; +} +/** + * As a workaround, _syncNpmrc() copies the .npmrc file to the target folder, and also trims + * unusable lines from the .npmrc file. If the source .npmrc file not exist, then _syncNpmrc() + * will delete an .npmrc that is found in the target folder. + * + * Why are we trimming the .npmrc lines? NPM allows environment variables to be specified in + * the .npmrc file to provide different authentication tokens for different registry. + * However, if the environment variable is undefined, it expands to an empty string, which + * produces a valid-looking mapping with an invalid URL that causes an error. Instead, + * we'd prefer to skip that line and continue looking in other places such as the user's + * home directory. + * + * IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities._syncNpmrc() + */ +function syncNpmrc(sourceNpmrcFolder, targetNpmrcFolder) { + const sourceNpmrcPath = path.join(sourceNpmrcFolder, '.npmrc'); + const targetNpmrcPath = path.join(targetNpmrcFolder, '.npmrc'); + try { + if (fs.existsSync(sourceNpmrcPath)) { + let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n'); + npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim()); + const resultLines = []; + // Trim out lines that reference environment variables that aren't defined + for (const line of npmrcFileLines) { + // This finds environment variable tokens that look like "${VAR_NAME}" + const regex = /\$\{([^\}]+)\}/g; + const environmentVariables = line.match(regex); + let lineShouldBeTrimmed = false; + if (environmentVariables) { + for (const token of environmentVariables) { + // Remove the leading "${" and the trailing "}" from the token + const environmentVariableName = token.substring(2, token.length - 1); + if (!process.env[environmentVariableName]) { + lineShouldBeTrimmed = true; + break; + } + } + } + if (lineShouldBeTrimmed) { + // Example output: + // "; MISSING ENVIRONMENT VARIABLE: //my-registry.com/npm/:_authToken=${MY_AUTH_TOKEN}" + resultLines.push('; MISSING ENVIRONMENT VARIABLE: ' + line); + } + else { + resultLines.push(line); + } + } + fs.writeFileSync(targetNpmrcPath, resultLines.join(os.EOL)); + } + else if (fs.existsSync(targetNpmrcPath)) { + // If the source .npmrc doesn't exist and there is one in the target, delete the one in the target + fs.unlinkSync(targetNpmrcPath); + } + } + catch (e) { + throw new Error(`Error syncing .npmrc file: ${e}`); + } +} +/** + * Detects if the package in the specified directory is installed + */ +function isPackageAlreadyInstalled(packageInstallFolder) { + try { + const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME); + if (!fs.existsSync(flagFilePath)) { + return false; + } + const fileContents = fs.readFileSync(flagFilePath).toString(); + return fileContents.trim() === process.version; + } + catch (e) { + return false; + } +} +/** + * Removes the following files and directories under the specified folder path: + * - installed.flag + * - + * - node_modules + */ +function cleanInstallFolder(rushCommonFolder, packageInstallFolder) { + try { + const flagFile = path.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME); + if (fs.existsSync(flagFile)) { + fs.unlinkSync(flagFile); + } + const packageLockFile = path.resolve(packageInstallFolder, 'package-lock.json'); + if (fs.existsSync(packageLockFile)) { + fs.unlinkSync(packageLockFile); + } + const nodeModulesFolder = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME); + if (fs.existsSync(nodeModulesFolder)) { + const rushRecyclerFolder = ensureAndJoinPath(rushCommonFolder, 'temp', 'rush-recycler', `install-run-${Date.now().toString()}`); + fs.renameSync(nodeModulesFolder, rushRecyclerFolder); + } + } + catch (e) { + throw new Error(`Error cleaning the package install folder (${packageInstallFolder}): ${e}`); + } +} +function createPackageJson(packageInstallFolder, name, version) { + try { + const packageJsonContents = { + 'name': 'ci-rush', + 'version': '0.0.0', + 'dependencies': { + [name]: version + }, + 'description': 'DON\'T WARN', + 'repository': 'DON\'T WARN', + 'license': 'MIT' + }; + const packageJsonPath = path.join(packageInstallFolder, PACKAGE_JSON_FILENAME); + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2)); + } + catch (e) { + throw new Error(`Unable to create package.json: ${e}`); + } +} +/** + * Run "npm install" in the package install folder. + */ +function installPackage(packageInstallFolder, name, version) { + try { + console.log(`Installing ${name}...`); + const npmPath = getNpmPath(); + const result = childProcess.spawnSync(npmPath, ['install'], { + stdio: 'inherit', + cwd: packageInstallFolder, + env: process.env + }); + if (result.status !== 0) { + throw new Error('"npm install" encountered an error'); + } + console.log(`Successfully installed ${name}@${version}`); + } + catch (e) { + throw new Error(`Unable to install package: ${e}`); + } +} +/** + * Get the ".bin" path for the package. + */ +function getBinPath(packageInstallFolder, binName) { + const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin'); + const resolvedBinName = (os.platform() === 'win32') ? `${binName}.cmd` : binName; + return path.resolve(binFolderPath, resolvedBinName); +} +/** + * Write a flag file to the package's install directory, signifying that the install was successful. + */ +function writeFlagFile(packageInstallFolder) { + try { + const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME); + fs.writeFileSync(flagFilePath, process.version); + } + catch (e) { + throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`); + } +} +function installAndRun(packageName, packageVersion, packageBinName, packageBinArgs) { + const rushJsonFolder = findRushJsonFolder(); + const rushCommonFolder = path.join(rushJsonFolder, 'common'); + const packageInstallFolder = ensureAndJoinPath(rushCommonFolder, 'temp', 'install-run', `${packageName}@${packageVersion}`); + if (!isPackageAlreadyInstalled(packageInstallFolder)) { + // The package isn't already installed + cleanInstallFolder(rushCommonFolder, packageInstallFolder); + const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush'); + syncNpmrc(sourceNpmrcFolder, packageInstallFolder); + createPackageJson(packageInstallFolder, packageName, packageVersion); + installPackage(packageInstallFolder, packageName, packageVersion); + writeFlagFile(packageInstallFolder); + } + const statusMessage = `Invoking "${packageBinName} ${packageBinArgs.join(' ')}"`; + const statusMessageLine = new Array(statusMessage.length + 1).join('-'); + console.log(os.EOL + statusMessage + os.EOL + statusMessageLine + os.EOL); + const binPath = getBinPath(packageInstallFolder, packageBinName); + const result = childProcess.spawnSync(binPath, packageBinArgs, { + stdio: 'inherit', + cwd: process.cwd(), + env: process.env + }); + return result.status; +} +exports.installAndRun = installAndRun; +function runWithErrorAndStatusCode(fn) { + process.exitCode = 1; + try { + const exitCode = fn(); + process.exitCode = exitCode; + } + catch (e) { + console.error(os.EOL + os.EOL + e.toString() + os.EOL + os.EOL); + } +} +exports.runWithErrorAndStatusCode = runWithErrorAndStatusCode; +function run() { + const [nodePath, /* Ex: /bin/node */ // tslint:disable-line:no-unused-variable + scriptPath, /* /repo/common/scripts/install-run-rush.js */ rawPackageSpecifier, /* rimraf@^2.0.0 */ packageBinName, /* rimraf */ ...packageBinArgs /* [-f, myproject/lib] */] = process.argv; + if (path.basename(scriptPath).toLowerCase() !== 'install-run.js') { + // If install-run.js wasn't directly invoked, don't execute the rest of this function. Return control + // to the script that (presumably) imported this file + return; + } + if (process.argv.length < 4) { + console.log('Usage: install-run.js @ [args...]'); + console.log('Example: install-run.js rimraf@2.6.2 rimraf -f project1/lib'); + process.exit(1); + } + runWithErrorAndStatusCode(() => { + const rushJsonFolder = findRushJsonFolder(); + const rushCommonFolder = ensureAndJoinPath(rushJsonFolder, 'common'); + const packageSpecifier = parsePackageSpecifier(rawPackageSpecifier); + const name = packageSpecifier.name; + const version = resolvePackageVersion(rushCommonFolder, packageSpecifier); + if (packageSpecifier.version !== version) { + console.log(`Resolved to ${name}@${version}`); + } + return installAndRun(name, version, packageBinName, packageBinArgs); + }); +} +run(); +//# sourceMappingURL=install-run.js.map \ No newline at end of file From 008f604adf539520052c2b16d95ef441771ee9aa Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 15:25:06 -0700 Subject: [PATCH 05/12] Set up Travis --- .travis.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ef5ddbf2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: node_js +node_js: + - '8.9.4' +script: + - set -e + + - echo 'Checking for missing change logs...' && echo -en 'travis_fold:start:change\\r' + - git fetch origin master:refs/remotes/origin/master -a + - node common/scripts/install-run-rush.js change -v + - echo -en 'travis_fold:end:change\\r' + + - echo 'Checking for inconsistent dependency versions' && echo -en 'travis_fold:start:check\\r' + - node common/scripts/install-run-rush.js check + - echo -en 'travis_fold:end:check\\r' + + - echo 'Installing...' && echo -en 'travis_fold:start:install\\r' + - node common/scripts/install-run-rush.js install + - echo -en 'travis_fold:end:install\\r' + + - echo 'Building...' && echo -en 'travis_fold:start:build\\r' + - node common/scripts/install-run-rush.js rebuild --verbose --production + - echo -en 'travis_fold:end:build\\r' From 31682a24a26633ff60dfb50d1a97611a904559a5 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 15:46:16 -0700 Subject: [PATCH 06/12] PR feedback --- README.md | 25 +++++++++++++++++-- .../rush/browser-approved-packages.json | 4 +++ .../rush/nonbrowser-approved-packages.json | 4 --- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a2c7b6ea..8f834a4a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,29 @@ # Example Rush Monorepo This template is part of the documentation of the [Rush](https://rushjs.io/) tool. -It contains templates for all the Rush configuration files, and a simple setup that -builds two empty projects. +It contains documentated templates for all the standard Rush configuration files. +It also includes three barebones projects that illustrate some dependency +relationships in a Rush repo: + +- **apps/my-app**: The web application +- **libraries/my-controls**: A control library used by the application +- **tools/my-toolchain**: A NodeJS build tool used to compile the other projects + +(These projects are NOT meant to provide a realistic tool chain.) + + +# Building this repo + +To build the projects in this repo, try these shell commands: + +``` +npm install -g @microsoft/rush +rush install +rush build +``` + +For more information, see the documentation at: https://rushjs.io/ + # Contributing diff --git a/common/config/rush/browser-approved-packages.json b/common/config/rush/browser-approved-packages.json index 8afc821f..943c1a9f 100644 --- a/common/config/rush/browser-approved-packages.json +++ b/common/config/rush/browser-approved-packages.json @@ -2,6 +2,10 @@ { "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/approved-packages.schema.json", "packages": [ + { + "name": "my-controls", + "allowedCategories": [ "main" ] + }, { "name": "whatwg-fetch", "allowedCategories": [ "main" ] diff --git a/common/config/rush/nonbrowser-approved-packages.json b/common/config/rush/nonbrowser-approved-packages.json index 824a1a72..5999c830 100644 --- a/common/config/rush/nonbrowser-approved-packages.json +++ b/common/config/rush/nonbrowser-approved-packages.json @@ -6,10 +6,6 @@ "name": "colors", "allowedCategories": [ "tools" ] }, - { - "name": "my-controls", - "allowedCategories": [ "main" ] - }, { "name": "my-toolchain", "allowedCategories": [ "main" ] From bfeec008f6303a1730c939c9a8a8cbb60a35013c Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 15:57:28 -0700 Subject: [PATCH 07/12] Consolidate the tsconfig.json files into my-toolchain/includes/tsconfig-web.json --- apps/my-app/tsconfig.json | 32 ++--------------- libraries/my-controls/tsconfig.json | 32 ++--------------- tools/my-toolchain/includes/tsconfig-web.json | 36 +++++++++++++++++++ 3 files changed, 40 insertions(+), 60 deletions(-) create mode 100644 tools/my-toolchain/includes/tsconfig-web.json diff --git a/apps/my-app/tsconfig.json b/apps/my-app/tsconfig.json index 073e2559..72012f1a 100644 --- a/apps/my-app/tsconfig.json +++ b/apps/my-app/tsconfig.json @@ -1,36 +1,8 @@ { - "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./node_modules/my-toolchain/includes/tsconfig-web.json", "compilerOptions": { - "outDir": "lib", - - "forceConsistentCasingInFileNames": true, - "jsx": "react", - "declaration": true, - "sourceMap": true, - "inlineSources": true, - "experimentalDecorators": true, - "strictNullChecks": true, "types": [ - ], - - "module": "esnext", - "moduleResolution": "node", - "target": "es5", - "lib": [ - "es5", - "scripthost", - "es2015.collection", - "es2015.promise", - "es2015.iterable", - "dom" ] - }, - "include": [ - "**/*.ts" - ], - "exclude": [ - "node_modules", - "lib" - ] + } } diff --git a/libraries/my-controls/tsconfig.json b/libraries/my-controls/tsconfig.json index 073e2559..72012f1a 100644 --- a/libraries/my-controls/tsconfig.json +++ b/libraries/my-controls/tsconfig.json @@ -1,36 +1,8 @@ { - "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./node_modules/my-toolchain/includes/tsconfig-web.json", "compilerOptions": { - "outDir": "lib", - - "forceConsistentCasingInFileNames": true, - "jsx": "react", - "declaration": true, - "sourceMap": true, - "inlineSources": true, - "experimentalDecorators": true, - "strictNullChecks": true, "types": [ - ], - - "module": "esnext", - "moduleResolution": "node", - "target": "es5", - "lib": [ - "es5", - "scripthost", - "es2015.collection", - "es2015.promise", - "es2015.iterable", - "dom" ] - }, - "include": [ - "**/*.ts" - ], - "exclude": [ - "node_modules", - "lib" - ] + } } diff --git a/tools/my-toolchain/includes/tsconfig-web.json b/tools/my-toolchain/includes/tsconfig-web.json new file mode 100644 index 00000000..02dcbf4f --- /dev/null +++ b/tools/my-toolchain/includes/tsconfig-web.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "compilerOptions": { + "outDir": "../../../lib", + + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "declaration": true, + "sourceMap": true, + "inlineSources": true, + "experimentalDecorators": true, + "strictNullChecks": true, + "types": [ + ], + + "module": "esnext", + "moduleResolution": "node", + "target": "es5", + "lib": [ + "es5", + "scripthost", + "es2015.collection", + "es2015.promise", + "es2015.iterable", + "dom" + ] + }, + "include": [ + "../../../src/**/*.ts", + ], + "exclude": [ + "../../../node_modules", + "../../../lib" + ] +} From e6367793df01bff56be7f3e9eaf515786986b1ef Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 16:13:08 -0700 Subject: [PATCH 08/12] Fix PR build error --- rush.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rush.json b/rush.json index 5d7ff5ba..e08effb8 100644 --- a/rush.json +++ b/rush.json @@ -15,7 +15,8 @@ "gitPolicy": { // Require GitHub scrubbed e-mails "allowedEmailRegExps": [ - "[^@]+@users\\.noreply\\.github\\.com" + "[^@]+@users\\.noreply\\.github\\.com", + "travis@example\\.org" ], "sampleEmail": "mrexample@users.noreply.github.com" }, From 89a6556e057c4eeeec4dcedfcf8076596e52ed59 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 17:43:48 -0700 Subject: [PATCH 09/12] Eliminate warning about @types/colors --- common/config/rush/shrinkwrap.yaml | 12 +----------- tools/my-toolchain/package.json | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/common/config/rush/shrinkwrap.yaml b/common/config/rush/shrinkwrap.yaml index cd205260..8683ffb3 100644 --- a/common/config/rush/shrinkwrap.yaml +++ b/common/config/rush/shrinkwrap.yaml @@ -2,20 +2,12 @@ dependencies: '@rush-temp/my-app': 'file:projects/my-app.tgz' '@rush-temp/my-controls': 'file:projects/my-controls.tgz' '@rush-temp/my-toolchain': 'file:projects/my-toolchain.tgz' - '@types/colors': 1.2.1 '@types/node': 10.9.4 colors: 1.3.2 rimraf: 2.6.2 typescript: 3.0.3 whatwg-fetch: 3.0.0 packages: - /@types/colors/1.2.1: - dependencies: - colors: 1.3.2 - deprecated: 'This is a stub types definition. colors provides its own type definitions, so you don''t need this installed.' - dev: false - resolution: - integrity: sha512-7jNkpfN2lVO07nJ1RWzyMnNhH/I5N9iWuMPx9pedptxJ4MODf8rRV0lbJi6RakQ4sKQk231Fw4e2W9n3D7gZ3w== /@types/node/10.9.4: dev: false resolution: @@ -128,7 +120,6 @@ packages: version: 0.0.0 'file:projects/my-toolchain.tgz': dependencies: - '@types/colors': 1.2.1 '@types/node': 10.9.4 colors: 1.3.2 rimraf: 2.6.2 @@ -136,7 +127,7 @@ packages: dev: false name: '@rush-temp/my-toolchain' resolution: - integrity: sha512-OGtNAqgdxHzze+shuzbWwyq0Nm97Q2UmDy3kgo3ib88nfA5bfE077ZlV/m+djVmKLMmlEYOGViBzFrQMi/JmSA== + integrity: sha512-Bsw9RLje8o0Xf64piV/WYvGHUeIJr82qre7pjzVUExinr/nV9wQ/16XX+W+cRWoYdjcgSaIYdueikz6YQ+OtNQ== tarball: 'file:projects/my-toolchain.tgz' version: 0.0.0 registry: 'https://registry.npmjs.org/' @@ -146,7 +137,6 @@ specifiers: '@rush-temp/my-app': 'file:./projects/my-app.tgz' '@rush-temp/my-controls': 'file:./projects/my-controls.tgz' '@rush-temp/my-toolchain': 'file:./projects/my-toolchain.tgz' - '@types/colors': ^1.2.1 '@types/node': ^10.9.4 colors: ^1.3.2 rimraf: ^2.6.2 diff --git a/tools/my-toolchain/package.json b/tools/my-toolchain/package.json index fa7b7ba9..493bf036 100644 --- a/tools/my-toolchain/package.json +++ b/tools/my-toolchain/package.json @@ -10,7 +10,6 @@ "build": "rimraf ./lib/ && tsc" }, "dependencies": { - "@types/colors": "^1.2.1", "colors": "^1.3.2" }, "devDependencies": { From 9d3062f3d288504ee6f87fd46306116c79a69a24 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 18:10:22 -0700 Subject: [PATCH 10/12] Fix an issue where "bin" was trying to symlink to a script that didn't exist yet --- tools/my-toolchain/bin/my-build.js | 2 ++ tools/my-toolchain/package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tools/my-toolchain/bin/my-build.js diff --git a/tools/my-toolchain/bin/my-build.js b/tools/my-toolchain/bin/my-build.js new file mode 100644 index 00000000..783bb806 --- /dev/null +++ b/tools/my-toolchain/bin/my-build.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('../lib/start.js') diff --git a/tools/my-toolchain/package.json b/tools/my-toolchain/package.json index 493bf036..a53607be 100644 --- a/tools/my-toolchain/package.json +++ b/tools/my-toolchain/package.json @@ -4,7 +4,7 @@ "description": "An example toolchain used to build projects in this repo", "license": "MIT", "bin": { - "my-build": "lib/start.js" + "my-build": "bin/my-build.js" }, "scripts": { "build": "rimraf ./lib/ && tsc" From 952b89fc66a05d6f7c296b92f7bb6a3eab849573 Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 18:21:46 -0700 Subject: [PATCH 11/12] Tune up the .gitattributes and .gitignore files to make them more agnostic --- .gitattributes | 67 +--------------------------- .gitignore | 119 +++++++++++++++++++++++++------------------------ 2 files changed, 62 insertions(+), 124 deletions(-) diff --git a/.gitattributes b/.gitattributes index 02d01126..532bfc5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,68 +1,5 @@ -# Prevent Git to auto detect text files and perform LF normalization. -* -text - -# The item with `binary` is treated as binary file. -# The item with `eol=lf` is converted to LF on checkin, back to LF on checkout. -# The item with `eol=crlf` is converted to LF on checkin, back to CRLF on checkout. - -# To get full extension list in the repo, remove the node_modules folder and run the following PowerShell cmdlet. -# PS> Get-ChildItem . -Recurse | Where-Object { -not $_.PSIsContainer } | ForEach-Object { $_.Extension.ToLower() } | Sort-Object | Get-Unique - -# If new extensions are added, please refresh the repo with the following commands. -# Reference: https://git-scm.com/docs/gitattributes -# > rm .git/index # Remove the index to force Git to -# > git reset # re-scan the working directory -# > git status # Show files that will be normalized -# > git add -u -# > git add .gitattributes -# > git commit -m "Apply end-of-line normalization based on updated .gitattributes file" - -*.aspx text eol=crlf -*.bowerrc text eol=lf -*.cmd text eol=crlf -*.command text eol=lf -*.config text eol=crlf -*.cs text eol=crlf -*.csproj text eol=crlf -*.css text eol=crlf -*.dll binary -*.editorconfig text eol=lf -*.eot binary -*.example text eol=crlf -*.exe binary -*.gif binary -*.gitattributes text eol=lf -*.gitignore text eol=lf -*.gitmodules text eol=lf -*.html text eol=crlf -*.ico binary -*.jpg binary -*.js text eol=crlf -*.json text eol=crlf -*.less text eol=crlf -*.map text eol=lf -*.md text eol=crlf -*.npmignore text eol=lf -*.png binary -*.ps1 text eol=crlf -*.rels text eol=crlf -*.resx text eol=crlf -*.scss text eol=crlf -*.sln text eol=crlf -*.svg text elf=lf -*.ts text eol=crlf -*.tsx text eol=crlf -*.ttf binary -*.woff binary -*.wsp binary -*.xml text eol=crlf - -# NPM "bin" scripts MUST have LF, or else the executable fails to run on Mac. -# This fnmatch expression only matches files in a "bin" folder and without -# a period in the filename. -/*/*/bin/+([!.]) -text - # Don't allow people to merge changes to these generated files, because the result -# may be invalid. You need to run "rush generate" again. +# may be invalid. You need to run "rush update" again. shrinkwrap.yaml merge=binary npm-shrinkwrap.json merge=binary +yarn.lock merge=binary diff --git a/.gitignore b/.gitignore index 1f8b26db..1901798d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,67 +1,68 @@ -# Windows OS Files -$RECYCLE.BIN/ -Desktop.ini -Thumbs.db -ehthumbs.db - -# Mac OSX Files -.AppleDouble -.DS_Store -.LSOverride -.Spotlight-V100 -.Trashes -._* - -# Package files -app -app-min -bower_components +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul coverage -local -dist -jspm_packages + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next + +# Common toolchain intermediate files lib lib-amd lib-es6 -node_modules -npm-debug.log -npminstall-log.txt temp # Rush files -**/*.build.error.log -**/*.build.log -/common/apiDocs/json/** -/common/last-install.flag -/common/last-install.log -/common/local-npm -/common/local-npm/** -/common/local-rush -/common/local-rush/** -/common/npm-cache -/common/npm-cache/** -/common/npm-local -/common/npm-local/** -/common/npm-tmp -/common/npm-tmp/** -/common/rush-link.json -/common/rush-recycler +common/temp/** package-deps.json - -# IDE files -*.bak -*.csproj.user -*.sublime-project -*.sublime-workspace -*.suo -*.userosscache -.idea -.vs/ -/.settings/ -bin/ - -# Ignore VS Code personal settings, but keep a root-level setting -/*/**/.vscode/ - -# Build artifacts -**/*.scss.ts From 48feeb3ff7a3a5ddbd9f5926eace0c508bafbdad Mon Sep 17 00:00:00 2001 From: pgonzal Date: Tue, 11 Sep 2018 18:24:06 -0700 Subject: [PATCH 12/12] Remove nonstandard --production switch --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ef5ddbf2..e865bcbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,5 +18,5 @@ script: - echo -en 'travis_fold:end:install\\r' - echo 'Building...' && echo -en 'travis_fold:start:build\\r' - - node common/scripts/install-run-rush.js rebuild --verbose --production + - node common/scripts/install-run-rush.js rebuild --verbose - echo -en 'travis_fold:end:build\\r'