diff --git a/.circleci/config.yml b/.circleci/config.yml index 7f1043649d..c7986ba409 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,6 @@ jobs: docker: - image: circleci/node:8.12.0-stretch-browsers working_directory: ~/repo - steps: - checkout - restore_cache: @@ -23,14 +22,15 @@ jobs: - ./node_modules - /home/circleci/.cache/Cypress key: yarn-dependencies-{{ checksum "yarn.lock" }} +# we should use- run: yarn start e2e.prepare + - run: yarn start build.electron + - run: yarn start dev.copy-assets.electron + - run: yarn start e2e.fixtures - run: yarn start format.check - - run: yarn start lint.against.origin-master - - run: yarn start dev.server.gen.electron - - run: yarn start test.against.origin-master - - run: yarn start e2e.prepare + - run: yarn start lint.affected.origin-master + - run: yarn start test.affected.origin-master - run: command: yarn start e2e.ci - no_output_timeout: 20m + no_output_timeout: 5m environment: CYPRESS_RECORD_KEY: b8ec9ad7-505f-48bb-9990-e8d5627bac26 - - run: yarn start package.ci diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f43210c26d..4b6c76f128 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,31 +8,54 @@ We would love for you to contribute to Angular Console! Read this document to se We are trying to keep GitHub issues for bug reports and feature requests. Stack Overflow is a much better place to ask general questions about how to use Angular Console. +## Two Platforms -## Running Dev +Angular Console runs on two platforms: -After cloning the project run: `yarn`. +* Electron +* VSCode + +The two versions of Angular Console share most of the code, but they are bundled differently. The dev experience is set up around the electron version. -After that, run `yarn start dev.prepare.electron`. Every time you add or remove dependencies in electron/package.json, you will need to rerun `dev.prepare`. -After this, run `yarn start dev.up` to start the dev environment. The application will start the process listening on port 4200. +## Development + +After cloning the project run: `yarn`. -You can also build the electron app by running `yarn start mac.electron-pack`, `yarn start win.electron-pack` or `yarn start linux.electron-pack` and then run it using `yarn start mac.start-electron`, `yarn start win.start-electron` or `yarn start linux.start-electron`. +After that, run `yarn start prepare.electron`. Every time you add or remove dependencies in electron/package.json, you will need to rerun `prepare.electron`. +After this, run `yarn start dev.up` to start the dev environment. The application will start the process listening on port 4200. The development is done in the browser, but the server uses electron. -## Running Unit Tests +### Running Unit Tests * Run `yarn start test` to run unit tests. -## Running E2e Tests +### Running E2e Tests -* Run `yarn start e2e.fixtures` to create fixtures. This will create a few projects in the tmp folder you can develop against or run e2e tests against. -* Run `yarn start e2e.run` to run e2e tests. This will compile and frontend and the backend, and run cypress tests (The fixtures must be created). -* Run `yarn start e2e.up` to server the app and launch cypress. (The fixtures must be created). This is useful for development. +* Run `yarn start e2e.prepare` to build the project and create fixtures. This will create a few projects in the tmp folder you can develop against or run e2e tests against. +* Run `yarn start e2e.ci` to run e2e tests. This will compile and frontend and the backend, and run cypress tests (The fixtures must be created). +* Run `yarn start e2e.up` to serve the app and launch cypress. (The fixtures must be created). This is useful for development. Cypress, which we use to run e2e tests, records the videos of the tests ran on CI. You can access them here: [https://dashboard.cypress.io/#/projects/x2ebye/runs](https://dashboard.cypress.io/#/projects/x2ebye/runs). This is very useful for troubleshooting. +## Building Electron App + +You can build the electron app by running `yarn start package.electronMac` or `yarn start package.electronWin`. Usually, you only need to do it locally if you change something related to electron-builder. + + + +## Building VSCode Plugin + +You can build the electron app by running `yarn start package.vscode`. Usually, you only need to do it locally if you change something related to the vscode setup. + +If you are working on the plugin, run: + +* `yarn start prepare.vscode` +* Hit F5 + + + ## Submitting a PR Please follow the following guidelines: @@ -42,7 +65,7 @@ Run the following commands to make sure the linting and the tests pass. * `yarn start format.check` * `yarn start lint` * `yarn start test` -* `yarn start e2e.fixtures` +* `yarn start e2e.prepare` * `yarn start e2e.up` If `yarn start format.check` fails, run `yarn start format`. diff --git a/README.md b/README.md index 538db9f1ff..f86bff3dca 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # The Power of the Angular CLI. The Convenience of an App. +

@@ -11,6 +12,7 @@ [![License](https://img.shields.io/npm/l/@nrwl/schematics.png)](https://opensource.org/licenses/MIT)
+

-1; } catch (e) { return false; diff --git a/libs/server/src/lib/server.module.ts b/libs/server/src/lib/server.module.ts index 51cce697a3..481653dacd 100644 --- a/libs/server/src/lib/server.module.ts +++ b/libs/server/src/lib/server.module.ts @@ -46,10 +46,7 @@ export function createServerModule(exports: string[], providers: Provider[]) { GraphQLModule.forRoot({ typePaths: [ path.join(__dirname, 'assets/schema.graphql'), - path.join( - __dirname, - './node_modules/@nrwl/angular-console-enterprise-electron/schema.graphql' - ) + path.join(__dirname, 'assets/extensions-schema.graphql') ], bodyParserConfig: true }) diff --git a/package-scripts.js b/package-scripts.js index bc8027fc18..8fbe87de0b 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -9,7 +9,7 @@ function electronOrVscode(command) { }; } -function against(affectedCommand) { +function affected(affectedCommand) { return { 'origin-master': `nx affected:${affectedCommand} --base=origin/master --parallel`, 'upstream-master': `nx affected:${affectedCommand} --base=upstream/master --parallel` @@ -24,6 +24,7 @@ function electronBuilder(platform, dashP, extraFlags) { const ELECTRON_BUNDLE_PATH = join('dist', 'apps', 'electron'); const APPLICATION_BUNDLE_PATH = join('dist', 'apps', 'APPLICATION'); + const assetMappings = { 'ng-cmd': { from: join('tools', 'win', '.bin', 'ng.cmd'), @@ -39,6 +40,14 @@ const assetMappings = { 'Release' ) }, + 'extensions-schema': { + from: join('./node_modules', '@nrwl', 'angular-console-enterprise-electron', 'schema.graphql'), + to: join( + APPLICATION_BUNDLE_PATH, + 'assets', + 'extensions-schema.graphql' + ) + }, 'server-assets': { from: join('libs', 'server', 'src', 'assets', '*'), to: join(APPLICATION_BUNDLE_PATH, 'assets') @@ -63,10 +72,12 @@ module.exports = { readme: `shx cp ${assetMappings['readme'].from} ${ assetMappings['readme'].to }`, + 'extensions-schema': `shx cp ${assetMappings['extensions-schema'].from} ${ + assetMappings['extensions-schema'].to + }`, cli: 'node ./tools/scripts/patch-cli.js' }) ), - 'start-electron': `NODE_ENV=development electron ${ELECTRON_BUNDLE_PATH}`, server: { default: nps.series.nps( 'dev.server.gen-and-build.electron', @@ -95,8 +106,8 @@ module.exports = { }), cypress: nps.concurrent({ server: 'nps dev.server', - frontend: 'ng serve angular-console --configuration cypress' - }) + frontend: 'ng run angular-console:serve:cypress' + }), } }, prepare: { @@ -109,13 +120,15 @@ module.exports = { ) }, package: { - // NOTE: This command should be run on a mac with Parallels installed - electron: nps.series.nps( - 'prepare.electron', + electronMac: nps.series( + 'nps prepare.electron', electronBuilder('--mac', 'never'), - electronBuilder('--win', 'never'), electronBuilder('--linux', 'never') ), + electronWin: nps.series( + 'nps prepare.electron', + electronBuilder('--win', 'never'), + ), vscode: nps.series( 'nps prepare.vscode', `shx rm -rf ${assetMappings['node-pty-prebuilt'].to}]`, @@ -123,35 +136,23 @@ module.exports = { assetMappings['node-pty-prebuilt'].to }`.replace(/APPLICATION/g, 'vscode'), `node ${join('tools', 'scripts', 'vscode-vsce.js')}` - ), - ci: nps.concurrent({ - // electron: electronBuilder('--mac --linux', 'never'), - vscode: 'nps package.vscode' - }) + ) }, publish: { - // NOTE: This command should be run on a mac with Parallels installed - electron: nps.series.nps( - 'dev.prepare', - electronBuilder('--mac', 'always'), + electronWin: nps.series.nps( + 'prepare.electron', electronBuilder( '--win', 'always', '--config.win.certificateSubjectName="Narwhal Technologies Inc."' - ), - electronBuilder('--linux', 'always') + ) ) }, e2e: { - build: nps.series.nps( - 'build.electron.cypress', - 'dev.copy-assets.electron' - ), fixtures: 'node ./tools/scripts/set-up-e2e-fixtures.js', - prepare: nps.concurrent.nps('e2e.build', 'e2e.fixtures'), + prepare: nps.concurrent.nps('prepare.electron', 'e2e.fixtures'), up: 'node ./tools/scripts/e2e.js --watch', - headless: 'node ./tools/scripts/e2e.js --headless', - ci: 'node ./tools/scripts/e2e.js --headless' + ci: 'node ./tools/scripts/e2e.js --headless --record' }, format: { default: 'nx format:write', @@ -164,25 +165,25 @@ module.exports = { nxLint: 'nx lint', tsLint: 'nx affected:lint --all --parallel' }), - against: against('lint'), + affected: affected('lint'), fix: { default: 'nx affected:lint --all --parallel --fix', - against: against('lint --fix') + affected: affected('lint --fix') } }, build: { default: 'nx affected:build --all --parallel', - against: against('build'), + affected: affected('build'), ...electronOrVscode( - nps.concurrent({ - server: 'nps dev.server.gen-and-build.APPLICATION', - frontend: 'ng build angular-console --configuration=APPLICATION' - }) + nps.series( + 'nps dev.server.gen-and-build.APPLICATION', + 'ng build angular-console --configuration=APPLICATION' + ) ) }, test: { default: 'nx affected:test --all --parallel', - against: against('test') + affected: affected('test') }, 'install-dependencies': { vscode: `node ${join('tools', 'scripts', 'vscode-yarn.js')}`, diff --git a/package.json b/package.json index 3cb9282b11..cec406f03a 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,10 @@ "productName": "Angular Console", "copyright": "Copyright © 2018 Narwhal Technologies Inc", "asar": false, + "files": [ + "**/*", + "!**/node_modules/@schematics/**" + ], "extraResources": [ { "from": "dist/apps/electron/assets", @@ -46,7 +50,8 @@ "artifactName": "AngularConsole-${version}.${ext}" }, "win": { - "target": "nsis" + "target": "nsis", + "icon": "icons/icon.ico" }, "linux": { "target": [ @@ -128,9 +133,9 @@ "electron-builder": "20.28.4", "electron-installer-dmg": "2.0.0", "electron-packager": "13.0.1", - "electron-rebuild": "^1.8.2", "electron-store": "2.0.0", "electron-updater": "3.1.2", + "electron-rebuild": "^1.8.2", "express": "4.16.4", "fix-path": "2.1.0", "fontfaceobserver": "^2.1.0", diff --git a/tools/scripts/e2e.js b/tools/scripts/e2e.js index 6a6cfeb3c6..5553786160 100644 --- a/tools/scripts/e2e.js +++ b/tools/scripts/e2e.js @@ -3,7 +3,7 @@ const fs = require('fs'); const cp = require('child_process'); let dev; -const flags = process.argv.slice(2).join(' '); +let flags = process.argv.slice(2).join(' '); function runE2eTests() { try { @@ -24,10 +24,10 @@ function runE2eTests() { } try { - dev = cp.spawn(findInPath('yarn'), ['start', 'dev.server.start']); + dev = cp.spawn(findInPath('yarn'), ['start', 'dev.up.cypress']); dev.stdout.on('data', data => { console.log(data.toString()); - if (data.toString().indexOf('starting server on port 4201') > -1) { + if (data.toString().indexOf('Listening on port 4201') > -1) { runE2eTests(); } }); diff --git a/tools/scripts/postinstall.js b/tools/scripts/postinstall.js index 87d7d2c1f1..184ba3d943 100644 --- a/tools/scripts/postinstall.js +++ b/tools/scripts/postinstall.js @@ -1,5 +1,11 @@ const shell = require('shelljs'); +const os = require('os'); shell.exec('node ./node_modules/vscode/bin/install'); +if (os.platform() === 'win32') { + shell.exec(`.\\node_modules\\.bin\\electron-rebuild.cmd`); +} else { + shell.exec('./node_modules/.bin/electron-rebuild'); +} shell.rm('-rf', 'node_modules/cypress/node_modules/@types'); shell.rm('-rf', 'node_modules/@types/sinon-chai/node_modules/@types'); diff --git a/yarn.lock b/yarn.lock index 580652c5f3..9c30800f15 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9265,7 +9265,14 @@ no-case@^2.2.0, no-case@^2.3.2: dependencies: lower-case "^1.1.1" -node-abi@^2.0.0, node-abi@^2.2.0: +node-abi@^2.0.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.6.0.tgz#3adc69b28b334a0556fbadca378c7d18b8c82397" + integrity sha512-kCnEh6af6Z6DB7RFI/7LHNwqRjvJW7rgrv3lhIFoQ/+XhLPI/lJYwsk5vzvkldPWWgqnAMcuPF5S8/jj56kVOA== + dependencies: + semver "^5.4.1" + +node-abi@^2.2.0: version "2.5.1" resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.5.1.tgz#bb17288fc3b2f68fea0ed9897c66979fd754ed47" integrity sha512-oDbFc7vCFx0RWWCweTer3hFm1u+e60N5FtGnmRV6QqvgATGFH/XRR6vqWIeBVosCYCqt6YdIr2L0exLZuEdVcQ==