diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 000000000..faa8b6b62 --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,25 @@ +name: Node.js CI + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run scully:compile:all + - run: node ./dist/scully/scully --tds --host='0.0.0.0' + - run: npm run test + - run: npm run e2e:full + env: + CI: true diff --git a/.huskyrc b/.huskyrc index 4c5dae482..fd39a0d51 100644 --- a/.huskyrc +++ b/.huskyrc @@ -1,6 +1,6 @@ { "hooks": { "pre-commit": "pretty-quick --staged", - "pre-push": "npm run scully:precommit && start-server-and-test scully:r http://localhost:1668 e2e" + "pre-push": "npm run scully:precommit && npm run e2e:full" } } diff --git a/README.md b/README.md index dc62889e1..b9d8c525f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![Gitter](https://img.shields.io/gitter/room/scullyio/community)](https://gitter.im/scullyio/community) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![CLA assistant](https://cla-assistant.io/readme/badge/scullyio/scully)](https://cla-assistant.io/scullyio/scully) +![Node.js CI](https://github.com/scullyio/scully/workflows/Node.js%20CI/badge.svg) The best way to build the fastest Angular apps. Scully is a static site generator for Angular projects looking to embrace the JAMStack. diff --git a/cypress/integration/sampleBlog.spec.js b/cypress/integration/sampleBlog.spec.js index d915ef7ea..56b7437ca 100644 --- a/cypress/integration/sampleBlog.spec.js +++ b/cypress/integration/sampleBlog.spec.js @@ -10,13 +10,9 @@ context('check first integration test', () => { }); }); - it('Check the list of users after navigation', () => { - cy.visit('/home'); - cy.get('ul>li>a') - .contains('/user') - .click() - .get('a') - .contains('Leanne Graham'); + it('Check the list of users', () => { + cy.visit('/user'); + cy.get('a').contains('Leanne Graham'); }); it('Check is transferState exist in html', () => { diff --git a/package.json b/package.json index bb6aa40fd..654ff0310 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "test": "jest", "test:watch": "jest --watch", "e2e": "cypress run --spec 'cypress/integration/**/*' --browser chrome", + "e2e:full": "start-server-and-test scully:r http://localhost:1668 e2e", "tsc": "tsc", "scully:run": "npm run scully:dev:all -- serve", "scully:run:test": "npm run test && npm run e2e", diff --git a/scully/scully.ts b/scully/scully.ts index 01b153358..68bea69bc 100644 --- a/scully/scully.ts +++ b/scully/scully.ts @@ -15,7 +15,7 @@ import {logError, logWarn, yellow} from './utils/log'; import {startScully} from './utils/startup'; import {waitForServerToBeAvailable} from './utils/waitForServerToBeAvailable'; import {bootServe, isBuildThere, watchMode} from './watchMode'; -import {watch, removeStaticDist, openNavigator} from './utils/cli-options'; +import {watch, removeStaticDist, openNavigator, hostName} from './utils/cli-options'; const open = require('open'); /** the default of 10 is too shallow for generating pages. */ @@ -30,6 +30,9 @@ if (process.argv.includes('version')) { (async () => { /** make sure not to do something before the config is ready */ const scullyConfig = await loadConfig; + if (hostName) { + scullyConfig.hostName = hostName; + } if (process.argv.includes('killServer')) { await httpGetJson(`http://${scullyConfig.hostName}:${scullyConfig.appPort}/killMe`, { suppressErrors: true, diff --git a/scully/utils/cli-options.ts b/scully/utils/cli-options.ts index 8f424d130..8002ab817 100644 --- a/scully/utils/cli-options.ts +++ b/scully/utils/cli-options.ts @@ -53,3 +53,9 @@ export const {proxyConfigFile} = yargs .alias('proxy', 'proxyConfigFile') .alias('proxy', 'proxyConfig') .describe('proxy', 'Load proxy config from file').argv; + +export const {hostName} = yargs + .string('hostName') + .default('hostName', undefined) + .alias('host', 'hostName') + .describe('host', 'Add hostname for scully').argv; diff --git a/src/__tests__/transfer-state.spec.ts b/src/__tests__/transfer-state.spec.ts index 3d1a7f5b6..d74c072d2 100644 --- a/src/__tests__/transfer-state.spec.ts +++ b/src/__tests__/transfer-state.spec.ts @@ -1,6 +1,6 @@ import {readFileSync} from 'fs'; import {join} from 'path'; -import {extractTransferState, replaceIndexNG} from '../test-config.helper'; +import {cl, extractTransferState, replaceIndexNG} from '../test-config.helper'; describe('TransferState', () => { it('should add state to page 1', () => { diff --git a/src/test-config.helper.ts b/src/test-config.helper.ts index cf13473cc..f2ca2d0a0 100644 --- a/src/test-config.helper.ts +++ b/src/test-config.helper.ts @@ -40,6 +40,7 @@ export const separateTransferFromHtml = index => { if (index.indexOf(SCULLY_STATE_START) === -1) { return [index, null]; } + // Remove transfer state const [start, remaining] = index.split(SCULLY_STATE_START); const [transferStateBlob, end] = remaining.split(SCULLY_STATE_END); @@ -48,3 +49,7 @@ export const separateTransferFromHtml = index => { return [indexWithoutTransferState, transferState]; }; + +export const cl = (something: string) => { + console.log(something); +};