diff --git a/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap b/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap index 608164a6..67fc8e4b 100644 --- a/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap +++ b/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap @@ -40,7 +40,7 @@ Object { "writeFileCalls": Array [ Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && npm run types && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^3.1.3\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"js-yaml\\":\\"^3.13.1\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", @@ -147,7 +147,7 @@ Object { "writeFileCalls": Array [ Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && npm run types && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^3.1.3\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"js-yaml\\":\\"^3.13.1\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", @@ -326,7 +326,7 @@ Object { "writeFileCalls": Array [ Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && npm run types && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^3.1.3\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"js-yaml\\":\\"^3.13.1\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", @@ -492,7 +492,7 @@ Object { "writeFileCalls": Array [ Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=10.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"build\\":\\"npm run compile && npm run types && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"precz\\":\\"npm run compile\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"preversion\\":\\"npm run compile\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^3.1.3\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"^3.1.3\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^7.1.4\\",\\"http-auth-utils\\":\\"^2.5.0\\",\\"js-yaml\\":\\"^3.13.1\\",\\"knifecycle\\":\\"^9.1.1\\",\\"strict-qs\\":\\"^6.1.1\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.0\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.8.4\\",\\"@babel/core\\":\\"^7.9.0\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.8.3\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.9.0\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.8.3\\",\\"@babel/preset-env\\":\\"^7.9.0\\",\\"@babel/preset-typescript\\":\\"^7.9.0\\",\\"@babel/register\\":\\"^7.9.0\\",\\"@types/jest\\":\\"^25.1.4\\",\\"@typescript-eslint/eslint-plugin\\":\\"^2.26.0\\",\\"@typescript-eslint/parser\\":\\"^2.26.0\\",\\"axios\\":\\"^0.19.0\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^1.2.0\\",\\"eslint\\":\\"^6.8.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.2\\",\\"jest\\":\\"^25.2.4\\",\\"jsdoc-to-markdown\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"prettier\\":\\"^2.0.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"typescript\\":\\"^3.8.3\\"},\\"eslintConfig\\":{\\"extends\\":\\"eslint:recommended\\",\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"],\\"overrides\\":[{\\"files\\":[\\"*.ts\\"],\\"rules\\":{\\"no-unused-vars\\":[1,{\\"args\\":\\"none\\"}]}}]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":\\"false\\"}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", diff --git a/packages/whook-create/src/services/createWhook.test.ts b/packages/whook-create/src/services/createWhook.test.ts index 68674e7a..1eed7a9e 100644 --- a/packages/whook-create/src/services/createWhook.test.ts +++ b/packages/whook-create/src/services/createWhook.test.ts @@ -174,12 +174,14 @@ Mr Bean "@whook/authorization": "", "@whook/cli": "", "@whook/cors": "", + "@whook/gcp-functions": "^3.1.3", "@whook/http-router": "", "@whook/http-transaction": "^3.1.3", "@whook/swagger-ui": "", "@whook/whook": "", "common-services": "^7.1.4", "http-auth-utils": "^2.5.0", + "js-yaml": "^3.13.1", "knifecycle": "^9.1.1", "strict-qs": "^6.1.1", "yerror": "^5.0.0", @@ -291,7 +293,7 @@ Mr Bean }, "private": true, "scripts": Object { - "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && NODE_ENV=\${NODE_ENV:-development} node bin/build", "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs", "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src", "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src", @@ -304,7 +306,7 @@ Mr Bean "prettier": "prettier --write 'src/**/*.ts'", "preversion": "npm run compile", "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "whook": "NODE_ENV=\${NODE_ENV:-development} whook", "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js", @@ -427,12 +429,14 @@ Mr Bean "@whook/authorization": "", "@whook/cli": "", "@whook/cors": "", + "@whook/gcp-functions": "^3.1.3", "@whook/http-router": "", "@whook/http-transaction": "^3.1.3", "@whook/swagger-ui": "", "@whook/whook": "", "common-services": "^7.1.4", "http-auth-utils": "^2.5.0", + "js-yaml": "^3.13.1", "knifecycle": "^9.1.1", "strict-qs": "^6.1.1", "yerror": "^5.0.0", @@ -544,7 +548,7 @@ Mr Bean }, "private": true, "scripts": Object { - "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && NODE_ENV=\${NODE_ENV:-development} node bin/build", "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs", "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src", "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src", @@ -557,7 +561,7 @@ Mr Bean "prettier": "prettier --write 'src/**/*.ts'", "preversion": "npm run compile", "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "whook": "NODE_ENV=\${NODE_ENV:-development} whook", "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js", @@ -665,12 +669,14 @@ Mr Bean "@whook/authorization": "", "@whook/cli": "", "@whook/cors": "", + "@whook/gcp-functions": "^3.1.3", "@whook/http-router": "", "@whook/http-transaction": "^3.1.3", "@whook/swagger-ui": "", "@whook/whook": "", "common-services": "^7.1.4", "http-auth-utils": "^2.5.0", + "js-yaml": "^3.13.1", "knifecycle": "^9.1.1", "strict-qs": "^6.1.1", "yerror": "^5.0.0", @@ -782,7 +788,7 @@ Mr Bean }, "private": true, "scripts": Object { - "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && NODE_ENV=\${NODE_ENV:-development} node bin/build", "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs", "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src", "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src", @@ -795,7 +801,7 @@ Mr Bean "prettier": "prettier --write 'src/**/*.ts'", "preversion": "npm run compile", "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "whook": "NODE_ENV=\${NODE_ENV:-development} whook", "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js", diff --git a/packages/whook-example/README.md b/packages/whook-example/README.md index dca4e184..de11b0af 100644 --- a/packages/whook-example/README.md +++ b/packages/whook-example/README.md @@ -57,6 +57,57 @@ Debug `knifecycle` internals (dependency injection issues): DEBUG=knifecycle npm run dev ``` +# Deploying with Google Cloud Functions + +Create a project and save its credentials to `.credentials.json`. + +Then install Terraform: +```sh +wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip +mkdir .bin +unzip -d .bin terraform_0.12.24_linux_amd64.zip +rm terraform_0.12.24_linux_amd64.zip +``` + +Then initialize the Terraform configuration: +```sh +.bin/terraform init ./terraform; +``` + +Create a new workspace: +```sh +.bin/terraform workspace new staging +``` + +Build the functions: +```sh +NODE_ENV=staging npm run build +``` + +Build the Whook commands Terraform depends on: +```sh +npm run compile +``` + +Plan the deployment: +```sh +.bin/terraform plan -var="project_id=my-project-1664" \ + -out=terraform.plan terraform +``` + +Apply changes: +```sh +# parallelism may be necessary to avoid hitting +# timeouts with a slow connection +.bin/terraform apply -parallelism=1 terraform.plan +``` + +Finally retrieve the API URL and enjoy! +```sh +.bin/terraform -var="project_id=my-project-1664" \ + output api_url +``` + [//]: # (::contents:end) # Authors diff --git a/packages/whook-example/package.json b/packages/whook-example/package.json index 766ec1f8..558c460e 100644 --- a/packages/whook-example/package.json +++ b/packages/whook-example/package.json @@ -42,7 +42,7 @@ } }, "scripts": { - "build": "npm run compile && NODE_ENV=${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && NODE_ENV=${NODE_ENV:-development} node bin/build", "cli": "env NODE_ENV=${NODE_ENV:-cli}", "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs", "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src", @@ -57,7 +57,7 @@ "prettier": "prettier --write 'src/**/*.ts'", "preversion": "npm run compile", "start": "NODE_ENV=${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "whook": "NODE_ENV=${NODE_ENV:-development} whook", "whook-dev": "PROJECT_SRC=\"$PWD/src\" NODE_ENV=${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js" @@ -80,12 +80,14 @@ "@whook/authorization": "^3.1.3", "@whook/cli": "^3.1.3", "@whook/cors": "^3.1.3", + "@whook/gcp-functions": "^3.1.3", "@whook/http-router": "^3.1.3", "@whook/http-transaction": "^3.1.3", "@whook/swagger-ui": "^3.1.3", "@whook/whook": "^3.1.3", "common-services": "^7.1.4", "http-auth-utils": "^2.5.0", + "js-yaml": "^3.13.1", "knifecycle": "^9.1.1", "strict-qs": "^6.1.1", "yerror": "^5.0.0", diff --git a/packages/whook-example/src/__snapshots__/cli.test.ts.snap b/packages/whook-example/src/__snapshots__/cli.test.ts.snap index 8808f1a4..f1faadbd 100644 --- a/packages/whook-example/src/__snapshots__/cli.test.ts.snap +++ b/packages/whook-example/src/__snapshots__/cli.test.ts.snap @@ -25,8 +25,16 @@ Object { ", "stdout": " -# Provided by \\"@whook/example\\": 1 commands +# Provided by \\"@whook/example\\": 2 commands - printEnv: A command printing every env values +- terraformValues: A command printing functions informations for Terraform + + +# Provided by \\"@whook/gcp-functions\\": 1 commands +- testHTTPLambda: A command for testing AWS HTTP lambda + + +# Provided by \\"@whook/cors\\": none # Provided by \\"@whook/cli\\": 6 commands @@ -39,9 +47,6 @@ Object { # Provided by \\"@whook/whook\\": none - - -# Provided by \\"@whook/cors\\": none ", } `; diff --git a/packages/whook-example/src/__snapshots__/index.test.ts.snap b/packages/whook-example/src/__snapshots__/index.test.ts.snap index 4cf01a09..1c5964ad 100644 --- a/packages/whook-example/src/__snapshots__/index.test.ts.snap +++ b/packages/whook-example/src/__snapshots__/index.test.ts.snap @@ -158,6 +158,9 @@ Object { Array [ "➰ - Plugin \\"@whook/cors\\" resolved to: /home/whoiam/projects/whook/packages/whook-cors/dist", ], + Array [ + "➰ - Plugin \\"@whook/gcp-functions\\" resolved to: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist", + ], Array [ "➰ - Plugin \\"@whook/whook\\" resolved to: /home/whoiam/projects/whook/dist", ], @@ -312,9 +315,15 @@ Object { Array [ "🚫 - Service \\"BASE_URL\\" not found in: /home/whoiam/projects/whook/packages/whook-cli/dist/services/BASE_URL", ], + Array [ + "🚫 - Service \\"BASE_URL\\" not found in: /home/whoiam/projects/whook/packages/whook-cors/dist/services/BASE_URL", + ], Array [ "🚫 - Service \\"BASE_URL\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/BASE_URL", ], + Array [ + "🚫 - Service \\"BASE_URL\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/BASE_URL", + ], Array [ "🚫 - Service \\"BUFFER_LIMIT\\" not found in: /home/whoiam/projects/whook/dist/services/BUFFER_LIMIT", ], @@ -327,6 +336,9 @@ Object { Array [ "🚫 - Service \\"BUFFER_LIMIT\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/BUFFER_LIMIT", ], + Array [ + "🚫 - Service \\"BUFFER_LIMIT\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/BUFFER_LIMIT", + ], Array [ "🚫 - Service \\"DECODERS\\" not found in: /home/whoiam/projects/whook/dist/services/DECODERS", ], @@ -339,6 +351,9 @@ Object { Array [ "🚫 - Service \\"DECODERS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/DECODERS", ], + Array [ + "🚫 - Service \\"DECODERS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/DECODERS", + ], Array [ "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in: /home/whoiam/projects/whook/dist/services/DEFAULT_ERROR_CODE", ], @@ -351,6 +366,9 @@ Object { Array [ "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/DEFAULT_ERROR_CODE", ], + Array [ + "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/DEFAULT_ERROR_CODE", + ], Array [ "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in: /home/whoiam/projects/whook/dist/services/DEFAULT_MECHANISM", ], @@ -363,6 +381,9 @@ Object { Array [ "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/DEFAULT_MECHANISM", ], + Array [ + "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/DEFAULT_MECHANISM", + ], Array [ "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in: /home/whoiam/projects/whook/dist/services/DEV_ACCESS_TOKEN", ], @@ -375,6 +396,9 @@ Object { Array [ "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/DEV_ACCESS_TOKEN", ], + Array [ + "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/DEV_ACCESS_TOKEN", + ], Array [ "🚫 - Service \\"ENCODERS\\" not found in: /home/whoiam/projects/whook/dist/services/ENCODERS", ], @@ -387,6 +411,9 @@ Object { Array [ "🚫 - Service \\"ENCODERS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/ENCODERS", ], + Array [ + "🚫 - Service \\"ENCODERS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/ENCODERS", + ], Array [ "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in: /home/whoiam/projects/whook/dist/services/IGNORED_FILES_PREFIXES", ], @@ -399,6 +426,9 @@ Object { Array [ "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/IGNORED_FILES_PREFIXES", ], + Array [ + "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/IGNORED_FILES_PREFIXES", + ], Array [ "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in: /home/whoiam/projects/whook/dist/services/IGNORED_FILES_SUFFIXES", ], @@ -411,6 +441,9 @@ Object { Array [ "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/IGNORED_FILES_SUFFIXES", ], + Array [ + "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/IGNORED_FILES_SUFFIXES", + ], Array [ "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in: /home/whoiam/projects/whook/dist/services/KEEP_ALIVE_TIMEOUT", ], @@ -423,6 +456,9 @@ Object { Array [ "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/KEEP_ALIVE_TIMEOUT", ], + Array [ + "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/KEEP_ALIVE_TIMEOUT", + ], Array [ "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in: /home/whoiam/projects/whook/dist/services/MAX_CLEAR_CHARS", ], @@ -435,6 +471,9 @@ Object { Array [ "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/MAX_CLEAR_CHARS", ], + Array [ + "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/MAX_CLEAR_CHARS", + ], Array [ "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in: /home/whoiam/projects/whook/dist/services/MAX_CLEAR_RATIO", ], @@ -447,6 +486,9 @@ Object { Array [ "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/MAX_CLEAR_RATIO", ], + Array [ + "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/MAX_CLEAR_RATIO", + ], Array [ "🚫 - Service \\"MAX_CONNECTIONS\\" not found in: /home/whoiam/projects/whook/dist/services/MAX_CONNECTIONS", ], @@ -459,6 +501,9 @@ Object { Array [ "🚫 - Service \\"MAX_CONNECTIONS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/MAX_CONNECTIONS", ], + Array [ + "🚫 - Service \\"MAX_CONNECTIONS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/MAX_CONNECTIONS", + ], Array [ "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in: /home/whoiam/projects/whook/dist/services/MAX_HEADERS_COUNT", ], @@ -471,6 +516,9 @@ Object { Array [ "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/MAX_HEADERS_COUNT", ], + Array [ + "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/MAX_HEADERS_COUNT", + ], Array [ "🚫 - Service \\"PARSERS\\" not found in: /home/whoiam/projects/whook/dist/services/PARSERS", ], @@ -483,6 +531,9 @@ Object { Array [ "🚫 - Service \\"PARSERS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/PARSERS", ], + Array [ + "🚫 - Service \\"PARSERS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/PARSERS", + ], Array [ "🚫 - Service \\"PROCESS_NAME\\" not found in: /home/whoiam/projects/whook/dist/services/PROCESS_NAME", ], @@ -495,6 +546,9 @@ Object { Array [ "🚫 - Service \\"PROCESS_NAME\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/PROCESS_NAME", ], + Array [ + "🚫 - Service \\"PROCESS_NAME\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/PROCESS_NAME", + ], Array [ "🚫 - Service \\"PROTOCOL\\" not found in: /home/whoiam/projects/whook/dist/services/PROTOCOL", ], @@ -507,6 +561,9 @@ Object { Array [ "🚫 - Service \\"PROTOCOL\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/PROTOCOL", ], + Array [ + "🚫 - Service \\"PROTOCOL\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/PROTOCOL", + ], Array [ "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in: /home/whoiam/projects/whook/dist/services/REDUCED_FILES_SUFFIXES", ], @@ -519,6 +576,9 @@ Object { Array [ "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/REDUCED_FILES_SUFFIXES", ], + Array [ + "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/REDUCED_FILES_SUFFIXES", + ], Array [ "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in: /home/whoiam/projects/whook/dist/services/SENSIBLE_HEADERS", ], @@ -531,6 +591,9 @@ Object { Array [ "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/SENSIBLE_HEADERS", ], + Array [ + "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/SENSIBLE_HEADERS", + ], Array [ "🚫 - Service \\"SENSIBLE_PROPS\\" not found in: /home/whoiam/projects/whook/dist/services/SENSIBLE_PROPS", ], @@ -543,6 +606,9 @@ Object { Array [ "🚫 - Service \\"SENSIBLE_PROPS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/SENSIBLE_PROPS", ], + Array [ + "🚫 - Service \\"SENSIBLE_PROPS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/SENSIBLE_PROPS", + ], Array [ "🚫 - Service \\"SHIELD_CHAR\\" not found in: /home/whoiam/projects/whook/dist/services/SHIELD_CHAR", ], @@ -555,6 +621,9 @@ Object { Array [ "🚫 - Service \\"SHIELD_CHAR\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/SHIELD_CHAR", ], + Array [ + "🚫 - Service \\"SHIELD_CHAR\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/SHIELD_CHAR", + ], Array [ "🚫 - Service \\"SIGNALS\\" not found in: /home/whoiam/projects/whook/dist/services/SIGNALS", ], @@ -567,6 +636,9 @@ Object { Array [ "🚫 - Service \\"SIGNALS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/SIGNALS", ], + Array [ + "🚫 - Service \\"SIGNALS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/SIGNALS", + ], Array [ "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in: /home/whoiam/projects/whook/dist/services/SOCKET_TIMEOUT", ], @@ -579,6 +651,9 @@ Object { Array [ "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/SOCKET_TIMEOUT", ], + Array [ + "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/SOCKET_TIMEOUT", + ], Array [ "🚫 - Service \\"STRINGIFYERS\\" not found in: /home/whoiam/projects/whook/dist/services/STRINGIFYERS", ], @@ -591,6 +666,9 @@ Object { Array [ "🚫 - Service \\"STRINGIFYERS\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/STRINGIFYERS", ], + Array [ + "🚫 - Service \\"STRINGIFYERS\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/STRINGIFYERS", + ], Array [ "🚫 - Service \\"TIMEOUT\\" not found in: /home/whoiam/projects/whook/dist/services/TIMEOUT", ], @@ -603,21 +681,27 @@ Object { Array [ "🚫 - Service \\"TIMEOUT\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/TIMEOUT", ], + Array [ + "🚫 - Service \\"TIMEOUT\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/TIMEOUT", + ], Array [ "🚫 - Service \\"getPingWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-cli/dist/handlers/getPing", ], Array [ - "🚫 - Service \\"getPingWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/handlers/getPing", + "🚫 - Service \\"getPingWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-cors/dist/handlers/getPing", ], Array [ - "🚫 - Service \\"optionsWithCORSWrapped\\" not found in: /home/whoiam/projects/whook/dist/handlers/optionsWithCORS", + "🚫 - Service \\"getPingWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/handlers/getPing", ], Array [ - "🚫 - Service \\"optionsWithCORSWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-cli/dist/handlers/optionsWithCORS", + "🚫 - Service \\"getPingWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/handlers/getPing", ], Array [ "🚫 - Service \\"optionsWithCORSWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/handlers/optionsWithCORS", ], + Array [ + "🚫 - Service \\"optionsWithCORSWrapped\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/handlers/optionsWithCORS", + ], Array [ "🚫 - Service \\"readDir\\" not found in: /home/whoiam/projects/whook/dist/services/readDir", ], @@ -630,6 +714,9 @@ Object { Array [ "🚫 - Service \\"readDir\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/readDir", ], + Array [ + "🚫 - Service \\"readDir\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/readDir", + ], Array [ "🚫 - Service \\"uniqueId\\" not found in: /home/whoiam/projects/whook/dist/services/uniqueId", ], @@ -642,6 +729,9 @@ Object { Array [ "🚫 - Service \\"uniqueId\\" not found in: /home/whoiam/projects/whook/packages/whook-example/src/services/uniqueId", ], + Array [ + "🚫 - Service \\"uniqueId\\" not found in: /home/whoiam/projects/whook/packages/whook-gcp-functions/dist/services/uniqueId", + ], Array [ "🛂 - Dynamic import of: /home/whoiam/projects/whook/dist/handlers/getPing", ], diff --git a/packages/whook-example/src/build.test.ts b/packages/whook-example/src/build.test.ts new file mode 100644 index 00000000..0ed5bc8e --- /dev/null +++ b/packages/whook-example/src/build.test.ts @@ -0,0 +1,35 @@ +import { exec } from 'child_process'; + +describe('build should work', () => { + [ + ['getPing', '{}'], + ['getOpenAPI', '{}'], + [ + 'getParameters', + '{ "aHeader": "true", "pathParam1":"4", "pathParam2":"a,b,c,d" }', + ], + ['getTime', '{}'], + ['getDelay', '{ "duration": 1 }'], + ['putEcho', '{"body": { "echo": "YOLO!" }}'], + ].forEach(([operationId, parameters]) => { + it(`with ${operationId} http lambdas`, async () => { + await execCommand( + `npx whook testHTTPFunction --name ${operationId} --parameters '${parameters}'`, + ); + }); + }); +}); + +async function execCommand( + command, +): Promise<{ stdout: string; stderr: string }> { + return new Promise((resolve, reject) => { + exec(command, (err, stdout, stderr) => { + if (err) { + reject(err); + return; + } + resolve({ stdout, stderr }); + }); + }); +} diff --git a/packages/whook-example/src/commands/terraformValues.ts b/packages/whook-example/src/commands/terraformValues.ts new file mode 100644 index 00000000..9acb78af --- /dev/null +++ b/packages/whook-example/src/commands/terraformValues.ts @@ -0,0 +1,258 @@ +import { extra, autoService } from 'knifecycle'; +import { LogService } from 'common-services'; +import { ENVService, identity } from '@whook/whook'; +import { readArgs, WhookCommandArgs, WhookCommandDefinition } from '@whook/cli'; +import { OpenAPIV3 } from 'openapi-types'; +import { flattenOpenAPI, getOpenAPIOperations } from '@whook/http-router'; +import YError from 'yerror'; +import { exec } from 'child_process'; +import crypto from 'crypto'; +import yaml from 'js-yaml'; + +export type WhookGoogleFunctionsBaseBuildConfiguration = { + private?: boolean; + memory?: number; + timeout?: number; + suffix?: string; + sourceOperationId?: string; +}; +export type WhookGoogleFunctionsBuildConfiguration = { + type: 'http'; +} & WhookGoogleFunctionsBaseBuildConfiguration; + +export const definition: WhookCommandDefinition = { + description: 'A command printing functions informations for Terraform', + example: `whook terraformValues --type paths`, + arguments: { + type: 'object', + additionalProperties: false, + required: ['type'], + properties: { + type: { + description: 'Type of values to return', + type: 'string', + enum: ['globals', 'paths', 'functions', 'function'], + }, + pretty: { + description: 'Pretty print JSON values', + type: 'boolean', + }, + functionName: { + description: 'Name of the function', + type: 'string', + }, + pathsIndex: { + description: 'Index of the paths to retrieve', + type: 'number', + }, + functionType: { + description: 'Types of the functions to return', + type: 'string', + }, + }, + }, +}; + +export default extra(definition, autoService(initTerraformValuesCommand)); + +async function initTerraformValuesCommand({ + API, + BASE_PATH, + log, + args, + execAsync = _execAsync, +}: { + API: OpenAPIV3.Document; + BASE_PATH: string; + log: LogService; + args: WhookCommandArgs; + execAsync: typeof _execAsync; +}) { + return async () => { + const { type, pretty, functionName, pathsIndex, functionType } = readArgs( + definition.arguments, + args, + ) as { + type: string; + pretty: boolean; + functionName: string; + pathsIndex: number; + functionType: string; + }; + const operations = getOpenAPIOperations(await flattenOpenAPI(API)); + const configurations = operations.map((operation) => { + const whookConfiguration = (operation['x-whook'] || { + type: 'http', + }) as WhookGoogleFunctionsBuildConfiguration; + const configuration = { + type: 'http', + timeout: '10', + memory: '128', + description: operation.summary || '', + enabled: 'true', + sourceOperationId: operation.operationId, + suffix: '', + ...Object.keys(whookConfiguration).reduce( + (accConfigurations, key) => ({ + ...accConfigurations, + [key]: whookConfiguration[key].toString(), + }), + {}, + ), + }; + const qualifiedOperationId = + (configuration.sourceOperationId || operation.operationId) + + (configuration.suffix || ''); + + return { + qualifiedOperationId, + method: operation.method.toUpperCase(), + path: operation.path, + ...configuration, + }; + }); + + if (type === 'globals') { + const commitHash = await execAsync(`git rev-parse HEAD`); + const commitMessage = ( + await execAsync(`git rev-list --format=%B --max-count=1 HEAD`) + ).split('\n')[1]; + const openapi2 = yaml.safeDump({ + swagger: '2.0', + info: { + title: API.info.title, + description: API.info.description, + version: API.info.version, + }, + host: '${infos_host}', + basePath: BASE_PATH, + schemes: ['https'], + produces: ['application/json'], + paths: configurations.reduce((accPaths, configuration) => { + const operation = operations.find( + ({ operationId }) => + operationId === configuration.sourceOperationId, + ); + + return { + ...accPaths, + [configuration.path]: { + ...(accPaths[configuration.path] || {}), + [configuration.method.toLowerCase()]: { + summary: configuration.description || '', + operationId: configuration.qualifiedOperationId, + ...(operation.parameters.length + ? { + parameters: operation.parameters.map( + ({ in: theIn, name, required }) => ({ + in: theIn, + name, + type: 'string', + required: required || false, + }), + ), + } + : undefined), + 'x-google-backend': { + address: `\${function_${configuration.qualifiedOperationId}}`, + }, + responses: { + '200': { description: 'x', schema: { type: 'string' } }, + }, + }, + }, + }; + }, {}), + }); + const openapiHash = crypto + .createHash('md5') + .update(JSON.stringify(API)) + .digest('hex'); + const infos = { + commitHash, + commitMessage, + openapi2, + openapiHash, + }; + log('info', JSON.stringify(infos)); + return; + } + + if (type === 'functions') { + const functions = configurations + .filter((configuration) => + functionType ? configuration.type === functionType : true, + ) + .reduce( + (accLambdas, configuration) => ({ + ...accLambdas, + [configuration.qualifiedOperationId]: + configuration.qualifiedOperationId, + }), + {}, + ); + + log('info', `${JSON.stringify(functions, null, pretty ? 2 : 0)}`); + return; + } + + if (!functionName) { + throw new YError('E_FUNCTION_NAME_REQUIRED'); + } + + const functionConfiguration = configurations.find( + ({ qualifiedOperationId }) => qualifiedOperationId === functionName, + ); + + log( + 'info', + `${JSON.stringify(functionConfiguration, null, pretty ? 2 : 0)}`, + ); + }; +} + +function buildPartName(parts: string[]): string { + return parts + .map((aPart, anIndex) => { + const realPartName = aPart.replace(/[{}]/g, ''); + + return anIndex + ? realPartName[0].toUpperCase() + realPartName.slice(1) + : realPartName; + }) + .join(''); +} + +function fixAWSSchedule(schedule: string): string { + if (typeof schedule === 'undefined') { + return ''; + } + + // The last wildcard is for years. + // This is a non-standard AWS addition... + // Also, we have to put a `?` in either + // day(month) or day(week) to fit AWS + // way of building cron tabs... + const fields = schedule.split(' '); + + if ('*' === fields[4]) { + fields[4] = '?'; + } else if ('*' === fields[2]) { + fields[2] = '?'; + } else { + throw new YError('E_BAD_AWS_SCHEDULE', schedule); + } + return `cron(${fields.concat('*').join(' ')})`; +} + +async function _execAsync(command: string): Promise { + return await new Promise((resolve, reject) => { + exec(command, (err: Error, stdout: string, stderr: string) => { + if (err) { + reject(YError.wrap(err, 'E_EXEC_FAILURE', stderr)); + return; + } + resolve(stdout.trim()); + }); + }); +} diff --git a/packages/whook-example/src/config/common/config.ts b/packages/whook-example/src/config/common/config.ts index adaf72cd..9111866a 100644 --- a/packages/whook-example/src/config/common/config.ts +++ b/packages/whook-example/src/config/common/config.ts @@ -5,6 +5,7 @@ import type { CORSConfig } from '@whook/cors'; import type { WhookConfigs } from '@whook/whook'; import type { AuthenticationConfig } from '../../services/authentication'; import type { APIConfig } from '../../services/API'; +import type { WhookCompilerConfig } from '@whook/gcp-functions'; const packageConf = require('../../../package'); const DEBUG_NODE_ENVS = ['test', 'development', 'staging']; @@ -15,6 +16,7 @@ export type AppConfigs = WhookConfigs & WhookAuthorizationConfig & WhookSwaggerUIConfig & CORSConfig & + WhookCompilerConfig & APIConfig; const CONFIG: AppConfigs = { @@ -29,6 +31,10 @@ const CONFIG: AppConfigs = { NODE_ENVS, DEBUG_NODE_ENVS: process.env.DEBUG ? NODE_ENVS : DEBUG_NODE_ENVS, SERVICE_NAME_MAP: {}, + COMPILER_OPTIONS: { + externalModules: ['portfinder', 'internal-ip'], + ignoredModules: ['ecstatic', 'swagger-ui-dist'], + }, ERRORS_DESCRIPTORS: { ...DEFAULT_ERRORS_DESCRIPTORS, E_INVALID_FAKE_TOKEN: { diff --git a/packages/whook-example/src/index.ts b/packages/whook-example/src/index.ts index 0555357b..17f1512d 100644 --- a/packages/whook-example/src/index.ts +++ b/packages/whook-example/src/index.ts @@ -9,8 +9,11 @@ import { } from '@whook/whook'; import initHTTPRouter from '@whook/http-router'; import wrapHTTPRouterWithSwaggerUI from '@whook/swagger-ui'; -import YError from 'yerror'; import type { Services } from 'knifecycle'; +import { + runBuild as runBaseBuild, + prepareBuildEnvironment as prepareBaseBuildEnvironment, +} from '@whook/gcp-functions'; // Per convention a Whook server main file must export // the following 3 functions to be composable: @@ -74,7 +77,12 @@ export async function prepareEnvironment( // Setup your own whook plugins or avoid whook defaults by leaving it empty $.register( - constant('WHOOK_PLUGINS', ['@whook/cli', '@whook/whook', '@whook/cors']), + constant('WHOOK_PLUGINS', [ + '@whook/gcp-functions', + '@whook/cors', + '@whook/cli', + '@whook/whook', + ]), ); return $; @@ -88,10 +96,8 @@ export async function prepareEnvironment( export async function runBuild( innerPrepareEnvironment = prepareBuildEnvironment, ): Promise { - throw new YError('E_NO_BUILD_IMPLEMENTED'); - // Usually, here you call the installed build - // return runBaseBuild(innerPrepareEnvironment); + return runBaseBuild(innerPrepareEnvironment); } // The `prepareBuildEnvironment` create the build @@ -102,7 +108,7 @@ export async function prepareBuildEnvironment( $ = await prepareEnvironment($); // Usually, here you call the installed build env - // $ = await prepareBaseBuildEnvironment($); + $ = await prepareBaseBuildEnvironment($); // The build often need to know were initializer // can be found to create a static build and @@ -114,7 +120,7 @@ export async function prepareBuildEnvironment( obfuscator: require.resolve( '@whook/http-transaction/dist/services/obfuscator', ), - log: require.resolve('common-services/dist/log'), + log: require.resolve('@whook/gcp-functions/dist/services/log'), time: require.resolve('common-services/dist/time'), delay: require.resolve('common-services/dist/delay'), }), diff --git a/packages/whook-example/terraform/functions.tf b/packages/whook-example/terraform/functions.tf new file mode 100644 index 00000000..c19b9f70 --- /dev/null +++ b/packages/whook-example/terraform/functions.tf @@ -0,0 +1,53 @@ +data "external" "functionConfiguration" { + for_each = data.external.functions.result + + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='function'", "--functionName='${each.key}'"] +} + +resource "google_storage_bucket" "storage_bucket" { + name = "whook_functions" +} + +data "archive_file" "functions" { + for_each = data.external.functions.result + + type = "zip" + source_dir = "./builds/${terraform.workspace}/${each.key}" + output_path = "./builds/${terraform.workspace}/${each.key}.zip" +} + +resource "google_storage_bucket_object" "storage_bucket_object" { + for_each = data.external.functions.result + + name = "${terraform.workspace}_${each.key}" + source = "./builds/${terraform.workspace}/${each.key}.zip" + bucket = google_storage_bucket.storage_bucket.name + depends_on = [data.archive_file.functions] +} + +resource "google_cloudfunctions_function" "cloudfunctions_function" { + for_each = data.external.functions.result + + name = "${terraform.workspace}_${each.key}" + description = data.external.functionConfiguration[each.key].result["description"] + runtime = "nodejs10" + + available_memory_mb = data.external.functionConfiguration[each.key].result["memory"] + timeout = data.external.functionConfiguration[each.key].result["timeout"] + source_archive_bucket = google_storage_bucket.storage_bucket.name + source_archive_object = google_storage_bucket_object.storage_bucket_object[each.key].name + trigger_http = true + entry_point = "default" +} + +# Seems to not work (no idea why) +# resource "google_cloudfunctions_function_iam_member" "invoker" { +# for_each = data.external.functions.result + +# project = google_cloudfunctions_function.cloudfunctions_function[each.key].project +# region = google_cloudfunctions_function.cloudfunctions_function[each.key].region +# cloud_function = google_cloudfunctions_function.cloudfunctions_function[each.key].name + +# role = "roles/cloudfunctions.invoker" +# member = "allUsers" +# } diff --git a/packages/whook-example/terraform/main.tf b/packages/whook-example/terraform/main.tf new file mode 100644 index 00000000..ff7c5946 --- /dev/null +++ b/packages/whook-example/terraform/main.tf @@ -0,0 +1,67 @@ +variable "project_id" { + type = string +} + +variable "region" { + type = string + default = "europe-west1" +} + +variable "zone" { + type = string + default = "europe-west1-b" +} + +variable "api_name" { + type = string + default = "api2" +} + +provider "google" { + version = "~> 3.14" + project = var.project_id + region = var.region + zone = var.zone + credentials = file(".credentials.json") +} + +provider "archive" { + version = "~> 1.3" +} + +provider "template" { + version = "~> 2.1.2" +} + +output "api_url" { + value = google_endpoints_service.endpoints_service.dns_address +} + +data "google_project" "project" { + project_id = var.project_id +} + +# imports the functions list +data "external" "functions" { + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='functions'", "--functionType='http'"] +} +data "external" "globals" { + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='globals'"] +} + +data "template_file" "template_file" { + template = data.external.globals.result["openapi2"] + + vars = merge({ + "infos_host" : "${var.api_name}.endpoints.${data.google_project.project.project_id}.cloud.goog" + }, zipmap( + [for key in keys(data.external.functions.result) : "function_${key}"], + [for key in keys(data.external.functions.result) : google_cloudfunctions_function.cloudfunctions_function[key].https_trigger_url] + )) +} + +resource "google_endpoints_service" "endpoints_service" { + service_name = "${var.api_name}.endpoints.${data.google_project.project.project_id}.cloud.goog" + project = data.google_project.project.project_id + openapi_config = data.template_file.template_file.rendered +}