Skip to content

Commit

Permalink
Add dbt-project type mapping
Browse files Browse the repository at this point in the history
This change introduces a new `dbt-project` repository type mapping, desgined specifically for dbt (data build tool) projects.
All dbt projects require a standard `dbt_project.yml` configuration file at a minimum, which is used in this script.
For reference, see https://docs.getdbt.com/docs/build/projects

Change-type: minor
Signed-off-by: Pranas Ziaukas <[email protected]>
  • Loading branch information
pranasziaukas committed Jun 12, 2024
1 parent d03dc79 commit 2d56a9b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/repo-type-mappings/dbt-project/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
49 changes: 49 additions & 0 deletions lib/repo-type-mappings/dbt-project/versionist.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2024 Balena Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';
const exec = require('child_process').exec;
const path = require('path');

// Update version info in `dbt_project.yml` by
// replacing the first `version: "..."` occurrence in the file
const updateDbtProjectVersion = (cwd, version, callback) => {
const dbtProjectYml = path.join(cwd, 'dbt_project.yml');
return exec(`sed -i '/^version:/ s/version: .*/version: "${version}"/' ${dbtProjectYml}`,
{
encoding: 'utf8',
}, callback);
};

module.exports = {
updateVersion: updateDbtProjectVersion,

transformTemplateDataAsync: {
preset: 'nested-changelogs',
upstream: [
{{#upstream}}
{
pattern: '{{{pattern}}}',
repo: '{{repo}}',
owner: '{{owner}}',
ref: '{{ref}}'
},
{{/upstream}}
]
},

template: 'default'
};

0 comments on commit 2d56a9b

Please sign in to comment.