Skip to content

Commit

Permalink
feat: added addDynamicPlugins to ConfigBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jpina1-godaddy committed Jan 14, 2025
1 parent f5c389c commit da57709
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
10 changes: 9 additions & 1 deletion packages/create-gasket-app/lib/scaffold/config-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class ConfigBuilder {
}

/**
* addEnvironment - Add environments to the gasket file and use the value in the plugins array
* addEnvironment - Add environments to the gasket file
* @param {string} key - name of the environment - `local.analyze`
* @param {object} value - configuration for the environment - `{
* dynamicPlugins: [
Expand All @@ -261,6 +261,14 @@ export class ConfigBuilder {
});
}

/**
* addDynamicPlugin - Add plugin to the the dynamicPlugins array
* @param {string} pluginName - Name of the plugin to add to the dynamicPlugins array - `@gasket/plugin-example`
*/
addDynamicPlugin(pluginName) {
this.add('dynamicPlugins', [`${pluginName}`]);
}

/**
* addImport - Add a non-plugin import to the gasket file
* @param {string} importName - name of the import used as a value - `import fs...`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,30 +512,44 @@ describe('ConfigBuilder', () => {
});
});


describe('.addEnvironment', () => {
describe('gasketConfig', () => {
let gasketConfig;
beforeEach(() => {
gasketConfig = new ConfigBuilder();
});

it('adds an environment to gasketConfig', () => {
gasketConfig.addEnvironment('test.env', { test: 'config ' });
expect(gasketConfig.fields.environments).toEqual({ 'test.env': { test: 'config ' } });
});
describe('.addDynamicPlugin', () => {
it('adds a dynamic plugin to gasketConfig', () => {
gasketConfig.addDynamicPlugin('pluginOne');
expect(gasketConfig.fields.dynamicPlugins).toEqual(['pluginOne']);
});

it('adds values to an environment in gasketConfig', () => {
gasketConfig.addEnvironment('test.env', { test: 'config ' });
gasketConfig.addEnvironment('test.env', { test2: 'config 2' });
expect(gasketConfig.fields.environments).toEqual({ 'test.env': { test: 'config ', test2: 'config 2' } });
it('adds multiple dynamic plugins to gasketConfig', () => {
gasketConfig.addDynamicPlugin('pluginOne');
gasketConfig.addDynamicPlugin('pluginTwo');
expect(gasketConfig.fields.dynamicPlugins).toEqual(['pluginOne', 'pluginTwo']);
});
});

it('adds multiple environments to gasketConfig', () => {
gasketConfig.addEnvironment('test.env', { test: 'config ' });
gasketConfig.addEnvironment('prod.env', { prod: 'config ' });
expect(gasketConfig.fields.environments).toEqual({
'test.env': { test: 'config ' },
'prod.env': { prod: 'config ' }
describe('.addEnvironment', () => {
it('adds an environment to gasketConfig', () => {
gasketConfig.addEnvironment('test.env', { test: 'config ' });
expect(gasketConfig.fields.environments).toEqual({ 'test.env': { test: 'config ' } });
});

it('adds values to an environment in gasketConfig', () => {
gasketConfig.addEnvironment('test.env', { test: 'config ' });
gasketConfig.addEnvironment('test.env', { test2: 'config 2' });
expect(gasketConfig.fields.environments).toEqual({ 'test.env': { test: 'config ', test2: 'config 2' } });
});

it('adds multiple environments to gasketConfig', () => {
gasketConfig.addEnvironment('test.env', { test: 'config ' });
gasketConfig.addEnvironment('prod.env', { prod: 'config ' });
expect(gasketConfig.fields.environments).toEqual({
'test.env': { test: 'config ' },
'prod.env': { prod: 'config ' }
});
});
});
});
Expand Down

0 comments on commit da57709

Please sign in to comment.