Skip to content

Commit

Permalink
feat: #1218 finish serverless, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuong Vu committed May 20, 2020
1 parent 5b61910 commit c3d6114
Show file tree
Hide file tree
Showing 14 changed files with 173 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"lint": "concurrently \"tsc --noEmit\" \"eslint --cache --ext=ts,tsx,js,svelte src\"",
"lint:fix": "eslint --cache --ext=ts,tsx,js,svelte src --fix",
"fetch-config": "yarn config-manager fetchConfig web-components",
"build:serverless": "serverless webpack --out dist --stage dev",
"release:server:dev": "serverless deploy --stage dev",
"build:serverless": "node ./scripts/build-serverless.js",
"release:server:dev": "node ./scripts/release-serverless.js",
"release:server:prod": "node ../../scripts/release/release-serverless.js web-components",
"release:npm:prod": "node ../../scripts/release/release-npm.js web-components --skip-edit-release-note",
"release:client:dev": "node ../../scripts/release/release-dev.js web-components reapit-web-components",
Expand Down
31 changes: 31 additions & 0 deletions packages/web-components/scripts/build-serverless.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const yargs = require('yargs')
const { spawn } = require('child_process')

const stage = yargs.argv.stage

// relative to the root of web-components package
const listServerlessYmlFiles = ['src/search-widget/server/serverless.yml']

const buildServerlessList = () => {
listServerlessYmlFiles.forEach(file => {
const build = spawn('serverless', ['webpack', '--config', file, '--out', 'dist', '--stage', stage])
build.stdout.on('data', function(data) {
console.info('stdout: ' + data.toString())
})

build.stderr.on('data', function(data) {
console.error('stderr: ' + data.toString())
})

build.on('exit', function(code) {
console.info(`Building ${file} exited with code ${code.toString()}`)
})

build.on('error', function(err) {
console.error(`An error happened \n${err}`)
process.exit(1)
})
})
}

buildServerlessList()
29 changes: 26 additions & 3 deletions packages/web-components/scripts/release-serverless.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
const path = require('path')
const yargs = require('yargs')
const { spawn } = require('child_process')

const stage = yargs.argv.stage

const listServerlessYmlFiles = [path.resolve(__dirname, '../src/search-widget/server/serverless.yml')]
// relative to the root of web-components package
const listServerlessYmlFiles = ['src/search-widget/server/serverless.yml']

const deployServerless = async () => {}
const deployServerlessList = () => {
listServerlessYmlFiles.forEach(file => {
const deploy = spawn('serverless', ['deploy', '--config', file, '--stage', stage])
deploy.stdout.on('data', function(data) {
console.info('stdout: ' + data.toString())
})

deploy.stderr.on('data', function(data) {
console.error('stderr: ' + data.toString())
})

deploy.on('exit', function(code) {
console.info(`Deploying ${file} exited with code ${code.toString()}`)
})

deploy.on('error', function(err) {
console.error(`An error happened \n${err}`)
process.exit(1)
})
})
}

deployServerlessList()
3 changes: 2 additions & 1 deletion packages/web-components/scripts/start-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ return (() => {
}
// eslint-disable-next-line max-len
const clientScript = `rollup -w -c './scripts/rollup.config.${packageName}.js' --environment APP_ENV:local`
const serverScript = 'serverless offline --out public/dist --stage local'
// eslint-disable-next-line max-len
const serverScript = `serverless offline --config src/${packageName}/server/serverless.yml --out public/dist --stage local`
const startClientServer = getStartClientServer(packageName)

const startDev = `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,102 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ReapitAppointmentBookingComponent should match a snapshot 1`] = `undefined`;
exports[`ReapitAppointmentBookingComponent should match a snapshot 1`] = `
Appointment_bookings {
"$$": Object {
"after_update": Array [],
"before_update": Array [],
"bound": Object {},
"callbacks": Object {},
"context": Map {},
"ctx": Array [
false,
1,
[Function],
[Function],
[Function],
[Function],
Object {
"bodyText": "css-kj8hgc",
"button": "css-1dv0ljc",
"dateCellHeader": "css-emo7go",
"formBlock": "css-ebxsuw",
"formButtonPrimary": "css-1lxnn63",
"formButtonSecondary": "css-rjv3cy",
"formError": "css-91pmmi",
"formHeader": "css-xk00h3",
"formInput": "css-l0zla6",
"formLabel": "css-1hy6hob",
"formSeparator": "css-yulbtv",
"globalStyles": "css-11c02ub",
"input": "css-90jyro",
"offerBanner": "css-1u7x4xu",
"pagination": "css-1ml0awe",
"paginationActive": "css-1ml0awe",
"primaryHeading": "css-1vpwbmy",
"primaryStrapline": "css-1k1azsg",
"resultItem": "css-hxgn9z",
"searchBox": "css-1kkxuu3",
"secondaryHeading": "css-x83nk",
"secondaryStrapline": "css-1ts0wow",
"selectedItem": "css-1uqw7mn",
"svgNavigation": "css-1r1r46p",
"timeCell": "css-5hl7fz",
"timeCellsContainer": "css-1fswrvx",
},
Object {
"baseBackgroundColor": "#f9fbfd",
"baseFontFamily": "\\"Roboto\\", sans-serif",
"basefontColor": "#12263f",
"basefontSize": "14px",
"breakPoints": Object {
"desktop": "",
"laptop": "",
"mobile": "",
"tablet": "",
},
"dateCellHeaderBackgroundColor": "#ececec",
"formButtonFontSize": "1.2rem",
"formHrSeparatorFontColor": "#e6e6e6",
"formLabelColor": "#737373",
"headingFontFamily": "\\"Open Sans\\", sans-serif",
"inverseFontColor": "#f9fbfd",
"mapAccentColor": "#7bc9eb",
"navigateButtonColor": "red",
"primaryAccentColor": "#0061a8",
"primaryHeadingFontSize": "24px",
"searchPlaceholder": "e.g. London or EC1N",
"secondaryAccentColor": "#1e2554",
"secondaryHeadingFontSize": "20px",
"secondaryfontColor": "#1e2554",
"timeCellBackgroundColor": "#dfdfdf",
"timeCellBackgroundColorHover": "#d3d3d3",
"timeCellsContainerBackgroundColor": "#f9f9f9",
},
"body",
],
"dirty": Array [
-1,
],
"fragment": Object {
"c": [Function],
"d": [Function],
"i": [Function],
"l": [Function],
"m": [Function],
"o": [Function],
"p": [Function],
},
"not_equal": [Function],
"on_destroy": Array [],
"on_mount": Array [],
"props": Object {
"parentSelector": 8,
"theme": 7,
},
"update": [Function],
},
"$capture_state": [Function],
"$inject_state": [Function],
"$set": [Function],
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ReapitAppointmentBookingComponent = ({
variant,
}: // apiKey,
// variant,
AppointmentBookingInitializers) => {
AppointmentBookingInitializers) =>
new AppointmentBooking({
target: document.querySelector(parentSelector) || document.body,
props: {
Expand All @@ -27,7 +27,7 @@ AppointmentBookingInitializers) => {
parentSelector,
},
})
}

Object.defineProperty(window, 'ReapitAppointmentBookingComponent', {
value: ReapitAppointmentBookingComponent,
})
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ exports[`appointment bookings it matches a snapshot 1`] = `
</div>
<div
class="date-time-picker-container svelte-114k6yq"
class="date-time-picker-container svelte-vy6ksi"
>
<div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`DateTimePicker it matches a snapshot 1`] = `
<body>
<div>
<div
class="date-time-picker-container svelte-114k6yq"
class="date-time-picker-container svelte-vy6ksi"
>
<div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ exports[`DateTimePicker it matches a snapshot 1`] = `
<body>
<div>
<div
class="time-cell-container time-cell-container-visible svelte-117k25"
class="time-cell-container time-cell-container-visible
undefined svelte-1jl2x7t"
>
<div>
1570747191389
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ afterEach(() => {

describe('data-cell', () => {
it('it matches a snapshot', () => {
const wrapper = render(DataCell, { date: dayjs() })
const wrapper = render(DataCell, { date: dayjs(), themeClasses: {} })
const { container } = wrapper

expect(container).toMatchSnapshot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ afterEach(() => {

describe('DateTimePicker', () => {
it('it matches a snapshot', () => {
const wrapper = render(DateTimePicker)
const wrapper = render(DateTimePicker, { themeClasses: {} })
const { container } = wrapper

expect(container).toMatchSnapshot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ afterEach(() => {

describe('DateTimePicker', () => {
it('it matches a snapshot', () => {
const wrapper = render(TimeCell, { startTime: dayjs() })
const wrapper = render(TimeCell, { startTime: dayjs(), themeClasses: {} })
const { container } = wrapper

expect(container).toMatchSnapshot()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
service: web-components
service: web-components.search-widget
plugins:
- serverless-webpack
- serverless-offline
- serverless-plugin-ifelse

custom:
env: ${file(../../../config.json)}
# relative to web-components package root
env: ${file(./config.json)}
webpack:
webpackConfig: 'webpack.config.js'
includeModules: true
Expand Down

0 comments on commit c3d6114

Please sign in to comment.