From 51c4ccd2c06619ea649f6ece4b53532f02360ae3 Mon Sep 17 00:00:00 2001 From: Cuong Vu Date: Fri, 22 May 2020 10:51:20 +0700 Subject: [PATCH] fix: #1218 fix service name not valid (#1307) --- packages/web-components/package.json | 4 ++-- packages/web-components/scripts/start-dev.js | 10 ++++++++-- .../src/search-widget/server/serverless.yml | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/web-components/package.json b/packages/web-components/package.json index d49296e09f..d8bad66179 100644 --- a/packages/web-components/package.json +++ b/packages/web-components/package.json @@ -53,7 +53,7 @@ "typescript": "~3.7.2" }, "scripts": { - "build:prod": "node ./scripts/build-prod.js", + "build:prod": "node ./scripts/build-prod.js --stage dev", "start:server": "serverless offline --out public/dist --stage local", "start:dev": "node ./scripts/start-dev.js", "test:dev": "cross-env TZ=UTC jest --watch --color", @@ -62,7 +62,7 @@ "lint:fix": "eslint --cache --ext=ts,tsx,js,svelte src --fix", "fetch-config": "yarn config-manager fetchConfig web-components", "build:serverless": "node ./scripts/build-serverless.js", - "release:server:dev": "node ./scripts/release-serverless.js", + "release:server:dev": "node ./scripts/release-serverless.js --stage dev", "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", diff --git a/packages/web-components/scripts/start-dev.js b/packages/web-components/scripts/start-dev.js index 3217f18f7b..65da73677a 100644 --- a/packages/web-components/scripts/start-dev.js +++ b/packages/web-components/scripts/start-dev.js @@ -1,5 +1,6 @@ #!/usr/bin/env node const fs = require('fs') +const path = require('path') const getMoveHtmlScript = packageName => { switch (packageName) { @@ -43,9 +44,14 @@ return (() => { const clientScript = `rollup -w -c './scripts/rollup.config.${packageName}.js' --environment APP_ENV:local` const serverConfigFile = `src/${packageName}/server/serverless.yml` const hasServer = fs.existsSync(serverConfigFile) - // eslint-disable-next-line max-len + // need to pass the apiKey into serverless offline for it to work locally + const { WEB_COMPONENT_API_KEY_SEARCH_WIDGET } = require(path.resolve(__dirname, '../config.json')) + const apiKeys = { + 'search-widget': WEB_COMPONENT_API_KEY_SEARCH_WIDGET, + } const serverScript = hasServer - ? `serverless offline --config ${serverConfigFile} --out public/dist --stage local` + ? // eslint-disable-next-line max-len + `serverless offline --config ${serverConfigFile} --out public/dist --stage local --apiKey ${apiKeys[packageName]}` : null const startClientServer = getStartClientServer(packageName) diff --git a/packages/web-components/src/search-widget/server/serverless.yml b/packages/web-components/src/search-widget/server/serverless.yml index 3b428b44e9..220aedd9ab 100644 --- a/packages/web-components/src/search-widget/server/serverless.yml +++ b/packages/web-components/src/search-widget/server/serverless.yml @@ -1,4 +1,4 @@ -service: web-components.search-widget +service: web-components-search-widget plugins: - serverless-webpack - serverless-offline @@ -33,7 +33,7 @@ provider: restApiId: ${self:custom.env.GATEWAY_REST_API_ID} restApiRootResourceId: ${self:custom.env.GATEWAY_REST_API_ROOT_RESOURCE_ID} deploymentBucket: - name: web-components.search-widget.${self:provider.stage} + name: web-components-search-widget-${self:provider.stage} blockPublicAccess: false environment: NODE_ENV: ${self:custom.env.NODE_ENV}