Skip to content

Latest commit

 

History

History
174 lines (110 loc) · 7.25 KB

CONTRIBUTING.md

File metadata and controls

174 lines (110 loc) · 7.25 KB

Contribution Guidelines

Prerequisites

The only prerequisite is Node.js, at the exact version pinned in .nvmrc. The CI and the release workflows use the same version, and Renovate keeps it up to date.

Node.js setup

The recommended way to get the right Node.js version is nvm:

  1. Install nvm following its installation instructions, then open a new shell.

  2. From the repository root, install the Node.js version pinned in .nvmrc:

    nvm install

    Without arguments, nvm install reads the version from .nvmrc, installs it and switches the current shell to it.

  3. Check that the active version matches .nvmrc:

    node --version
    cat .nvmrc

nvm switches the version only in the current shell. In every new shell, run from the repository root:

nvm use

When .nvmrc changes (e.g. after pulling a Node.js update from Renovate), nvm use reports that the new version is not installed: run nvm install again. To switch version automatically when entering the repository, see nvm's deeper shell integration.

Use the npm version bundled with Node.js, don't upgrade it separately.

Run a development environment

Install the dependencies:

npm ci

npm ci installs exactly the versions recorded in package-lock.json. Use npm install only to add or update a dependency.

Start Storybook:

npm run storybook

You'll find it served at http://localhost:6006. The UI will be hot-reloaded on any change.

Playground

The playground is a lightweight Vite app (separate from Storybook) intended as a quick interactive testing ground for components. Use it to set up ad-hoc test scenarios, experiment with component configurations, and validate behavior. Unlike Storybook, features like v-model and other Vue instance features fully work in the playground.

To start it, run:

npm run playground

Edit playground/App.vue to add the components you want to test. The app will be hot-reloaded on any change.

The playground is for local testing only: do not commit your scenarios or your changes to playground/App.vue. Describe what you tested in the pull request instead.

IDE support

VS Code is the recommended IDE. When you open the repository, it suggests installing the recommended extensions listed in .vscode/extensions.json:

Quality Standards

Code Style

Code style is enforced by ESLint and Prettier. You can run the linter with:

npm run lint

To check the formatting of the code:

npm run format

and to fix it:

npm run format-fix

During PRs the linter and the formatting check will be run automatically and report any error.

Commit messages

Commit messages MUST follow the Conventional Commits specification. During development on a branch you can avoid this format IF you plan to squash the commits before merging the PR, in this case the final commit message MUST follow the specification.

Building the library

You can build the components with:

npm run build

the result will be put in the dist folder. The CI and the release workflows run the same command.

Building the storybook

To build the storybook, run:

npm run build-storybook

the result will be put in the storybook-static folder, which can be served with any web server.

After the build, npm runs scripts/components-json.mjs (the postbuild-storybook script), which writes storybook-static/components.json: the list of the components and the patterns, with their descriptions and links, for coding agents and other tools that cannot run the Storybook. It is published at https://nethesis.github.io/vue-components/components.json. npm run storybook does not serve it.

Stories

Every component and every pattern has a stories file in stories, with a title that starts with Components/ or Patterns/. Its meta has a description, written in components.json and shown on the Docs page when the stories have the autodocs tag:

const meta = {
  title: 'Components/NeButton',
  component: NeButton,
  tags: ['autodocs'],
  parameters: {
    docs: {
      description: {
        component: 'Starts an action. …'
      }
    }
  }
} satisfies Meta<typeof NeButton>

The description says what the component is for, and which component to use instead in the cases it does not cover. When the writing guidelines of the Nebula Design System have a section for the texts of the component or the pattern, the description links it: Its texts follow [Modals](https://nethesis.github.io/nebula-design-system/?page=writing-guidelines#modals) in the writing guidelines. Leave out autodocs only for components that cover the page, such as NeModal and NeSideDrawer. When a component is deprecated, add [Deprecated] to its title and start its description with Deprecated: use <Name>, the component that replaces it, then say how to switch: the props, slots, events and types that change.

The build of the Storybook fails if a description is missing, if a deprecated component does not name an existing replacement, or if a component exported by src/main.ts has no stories.

Publishing the library

Releases are automated by release-please in .github/workflows/release-please.yml: on every push to main it keeps a release PR up to date with

  • Changelog
  • Package version automatically bumped based off the commit messages

Once that PR is merged, release-please creates the GitHub release and tags the new version. The tag triggers .github/workflows/release.yml, which builds dist and publishes the package to NPM.

The publish job does not use any NPM token: it authenticates with npm trusted publishing through GitHub OIDC, which also attaches a provenance attestation to the published version. This requires the id-token: write permission on the job and npm >= 11.5.1 on the runner (provided by the Node version pinned in .nvmrc). The trusted publisher registered on npmjs.com points at the release.yml workflow filename, so renaming that file breaks publishing.

Manual publishing

Manual publishing is a fallback only: it requires an NPM account with write access to the package, and the resulting version has no provenance attestation. You'll need to follow this procedure:

  • write a changelog entry in CHANGELOG.md
  • bump the version in package.json and package-lock.json
  • build the library using the command provided in Building the library

Finally, publish the library with:

npm publish