{"id":20612004,"url":"https://github.com/tcarrio/serverless-config-transformer","last_synced_at":"2025-08-10T22:02:56.669Z","repository":{"id":93830501,"uuid":"271574141","full_name":"tcarrio/serverless-config-transformer","owner":"tcarrio","description":"[Mirror] A simple package for transforming the Serverless config at build time","archived":false,"fork":false,"pushed_at":"2020-10-17T22:50:18.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T18:15:52.317Z","etag":null,"topics":["serverless","serverless-framework","typescript"],"latest_commit_sha":null,"homepage":"https://git.sr.ht/~tcarrio/serverless-config-transformer","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcarrio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T14:55:09.000Z","updated_at":"2020-10-18T00:31:55.000Z","dependencies_parsed_at":"2023-06-15T06:45:40.968Z","dependency_job_id":null,"html_url":"https://github.com/tcarrio/serverless-config-transformer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tcarrio/serverless-config-transformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fserverless-config-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fserverless-config-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fserverless-config-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fserverless-config-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcarrio","download_url":"https://codeload.github.com/tcarrio/serverless-config-transformer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fserverless-config-transformer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269794094,"owners_count":24476739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["serverless","serverless-framework","typescript"],"created_at":"2024-11-16T10:22:55.368Z","updated_at":"2025-08-10T22:02:56.591Z","avatar_url":"https://github.com/tcarrio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![npm (scoped)](https://img.shields.io/npm/v/@0xc/serverless-config-transformer)\n[![builds.sr.ht status](https://builds.sr.ht/~tcarrio/serverless-config-transformer/.build.yml.svg)](https://builds.sr.ht/~tcarrio/serverless-config-transformer/.build.yml?)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n# serverless-config-transformer\n\nA simple package for transforming the Serverless config at build time. This was\nused for a gulpfile initially, but should be applicable otherwise. The original\nidea was to allow local development plugins to be different from those used for\nthe production deployment.\n\n## How to use\n\nThis file is a reduced example based on a production gulpfile.\n\n```ts\nimport { dest, series, src, task } from \"gulp\";\nimport ts from \"gulp-typescript\";\nimport merge from \"merge2\";\nimport {\n  Serverless,\n  ServerlessConfigTransformer,\n} from \"@0xc/serverless-config-transformer\";\n/* eslint-disable @typescript-eslint/no-var-requires */\nconst del = require(\"del\");\nconst serverlessGulp = require(\"serverless-gulp\");\n\nconst currentFolder = \".\";\nconst backupFolder = \".backup\";\nconst slsFile = \"serverless.yml\";\n\nconst slsFilePath = `${currentFolder}/${slsFile}`;\nconst backupSlsFilePath = `${backupFolder}/${slsFile}`;\nconst overwrite = { overwrite: true };\n\nconst serverlessConfigTransformer = new ServerlessConfigTransformer({\n  converter: config =\u003e {\n    config.plugins = [\"serverless-webpack\"];\n    config.provider.package.include = [\"dist/**\"];\n    config.custom = { webpack: config.custom!.webpack };\n    config.functions = Object.keys(config.functions).reduce(\n      (functions, key) =\u003e ({\n        ...functions,\n        [key]: {\n          ...config.functions[key],\n          handler: config.functions[key].handler.replace(/^src\\//, \"dist/\"),\n        },\n      }),\n      {} as Serverless.Functions,\n    );\n\n    return config;\n  },\n});\n\nfunction backupConfig() {\n  return src(slsFilePath).pipe(dest(backupFolder));\n}\n\nfunction updateConfig() {\n  return src(slsFilePath, { read: true }).pipe(serverlessConfigTransformer);\n}\n\nfunction restoreConfig() {\n  return src(backupSlsFilePath).pipe(dest(currentFolder, overwrite));\n}\n\nconst tsProject = ts.createProject(\"tsconfig.build.json\");\nconst outDir = \"dist\";\n\nfunction compile(includeSourceMaps = false) {\n  return () =\u003e {\n    const srcs = tsProject.src().pipe(tsProject());\n\n    if (includeSourceMaps) {\n      return merge(srcs.js.pipe(dest(outDir)), srcs.dts.pipe(dest(outDir)));\n    }\n\n    return srcs.js.pipe(dest(outDir));\n  };\n}\n\nfunction clean() {\n  return del([outDir]);\n}\n\ntask(\"clean\", clean);\ntask(\"build\", series(\"clean\", compile(false)));\n\ntask(\"config:backup\", backupConfig);\ntask(\"config:update\", updateConfig);\ntask(\"config:restore\", restoreConfig);\n\ntask(\"predeploy\", series(\"config:backup\", \"config:update\", \"build\"));\ntask(\"postdeploy\", series(\"config:restore\"));\n```\n\nThis package only handles transformation of the Serverless config, which is a\nliteral file transformation. You should backup and restore the original config\nyourself. Or at the very least, **don't commit the changes made**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcarrio%2Fserverless-config-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcarrio%2Fserverless-config-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcarrio%2Fserverless-config-transformer/lists"}