How to use @geut/chast - 6 common examples

To help you get started, we’ve selected a few @geut/chast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geut / chan / packages / chan-core / transformer.js View on Github external
}

    // define the urls
    let releaseUrl;
    if (gitTemplate && gitBranch) {
      const lastRelease = releases[0];

      if (lastRelease) {
        releaseUrl = gitTemplate.replace('[prev]', `v${lastRelease.version}`).replace('[next]', `v${version}`);
      }

      // in the future the template v[version] could be defined by the user, maybe?
      unreleased.url = gitTemplate.replace('[prev]', `v${version}`).replace('[next]', gitBranch);
    }

    const newRelease = createRelease(
      {
        identifier: version.toLowerCase(),
        version,
        url: releaseUrl,
        yanked: isYanked,
        date
      },
      changes
    );

    tree.children = [preface, unreleased, newRelease, ...releases];
    return tree;
  }
github geut / chan / packages / chan-core / transformer.js View on Github external
function findActionOrCreate(action, release) {
  let name = action.toLowerCase().trim();
  name = name[0].toUpperCase() + name.substr(1);

  let actionNode = select(`action[name=${name}]`, release);

  if (actionNode) {
    return actionNode;
  }

  actionNode = createAction({ name });
  release.children.push(actionNode);
  return actionNode;
}
github geut / chan / packages / chan-core / transformer.js View on Github external
function findGroupOrCreate(group, action) {
  let groupNode = select(`group[name=${group}]`, action);

  if (groupNode) {
    return groupNode;
  }

  groupNode = createGroup({ name: group });
  action.children.push(groupNode);
  return groupNode;
}
github geut / chan / packages / chan-core / transformer.js View on Github external
function compile(tree, file) {
    const preface = select('preface', tree);

    if (preface && !overwrite) {
      file.fail(new Error('The changelog already exists.'), preface, 'addPreface');
    }

    tree.children = [
      createPreface(parse(tplPreface)),
      createRelease({
        identifier: 'unreleased',
        version: 'Unreleased',
        unreleased: true
      })
    ];

    return tree;
  }
github geut / chan / packages / chan-core / transformer.js View on Github external
return changes.reduce((result, { version = 'unreleased', action, group, value }) => {
      assert(value, '`value` is required');

      const release = select(`release[identifier=${version}]`, tree);

      if (!release) {
        file.message(`The release "${version}" was not found.`, tree, 'addChanges');
        return tree;
      }

      const actionNode = findActionOrCreate(action, release);
      const changeNode = createChange(parse(value));

      if (group) {
        const groupNode = findGroupOrCreate(group, actionNode);
        groupNode.children.push(changeNode);
      } else {
        actionNode.children.push(changeNode);
      }

      return tree;
    }, tree);
  }
github geut / chan / packages / chan-core / transformer.js View on Github external
function compile(tree, file) {
    const preface = select('preface', tree);

    if (preface && !overwrite) {
      file.fail(new Error('The changelog already exists.'), preface, 'addPreface');
    }

    tree.children = [
      createPreface(parse(tplPreface)),
      createRelease({
        identifier: 'unreleased',
        version: 'Unreleased',
        unreleased: true
      })
    ];

    return tree;
  }

@geut/chast

Unist compatible spec for changelogs and helpers to nodes creation

ISC
Latest version published 2 years ago

Package Health Score

46 / 100
Full package analysis

Similar packages