Skip to content

Commit

Permalink
fix(build): fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Jan 28, 2019
1 parent 61d73c3 commit a1df664
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 63 deletions.
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
docker:
- image: circleci/node:8.12.0-stretch-browsers
working_directory: ~/repo

steps:
- checkout
- restore_cache:
Expand All @@ -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
45 changes: 34 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# The Power of the Angular CLI. The Convenience of an App.


<p align="center">
<img src="https://raw.githubusercontent.com/nrwl/angular-console/master/static/angular-console-logo-with-text.jpg" width="256"/>
</p>
Expand All @@ -11,6 +12,7 @@
[![License](https://img.shields.io/npm/l/@nrwl/schematics.png)](https://opensource.org/licenses/MIT)

<hr>

<p align="center">
<a href="https://hubs.ly/H0g97pW0" style="display: block; padding: 1rem 0 2rem 0;" target="_blank">
<img
Expand Down
4 changes: 3 additions & 1 deletion apps/angular-console-e2e/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"video": true,
"videosFolder": "../../dist/out-tsc/apps/angular-console-e2e/videos",
"screenshotsFolder": "../../dist/out-tsc/apps/angular-console-e2e/screenshots",
"projectId": "x2ebye",
"chromeWebSecurity": false,
"baseUrl": "http://localhost:4201"
"numTestsKeptInMemory": 5,
"baseUrl": "http://localhost:4200"
}
1 change: 1 addition & 0 deletions libs/server/src/lib/api/read-editors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function hasVsCode(config: { insiders: boolean } = { insiders: false }) {
const appName = insiders
? 'Visual Studio Code - Insiders.app'
: 'Visual Studio Code.app';

return apps.indexOf(appName) > -1;
} catch (e) {
return false;
Expand Down
5 changes: 1 addition & 4 deletions libs/server/src/lib/server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
69 changes: 35 additions & 34 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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'),
Expand All @@ -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')
Expand All @@ -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',
Expand Down Expand Up @@ -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: {
Expand All @@ -109,49 +120,39 @@ 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}]`,
`shx cp -rf ${assetMappings['node-pty-prebuilt'].from} ${
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',
Expand All @@ -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')}`,
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -46,7 +50,8 @@
"artifactName": "AngularConsole-${version}.${ext}"
},
"win": {
"target": "nsis"
"target": "nsis",
"icon": "icons/icon.ico"
},
"linux": {
"target": [
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions tools/scripts/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
});
Expand Down
6 changes: 6 additions & 0 deletions tools/scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -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');
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit a1df664

Please sign in to comment.