Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(esm): convert to esm (#2569) #2607

Merged
merged 20 commits into from Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9eab1ad
feat(esm): convert to esm (#2569)
travi Nov 11, 2022
f7c85e3
test(index): forced plugins to use semantic-release beta
travi Nov 11, 2022
78ea3ba
Merge pull request #2606 from semantic-release/travi/esm
travi Nov 11, 2022
1b62548
test: aligned pluginName with naming for functions
travi Nov 13, 2022
0ab8d9a
Merge pull request #2610 from semantic-release/index-test
travi Nov 16, 2022
cf6befa
fix(secrets-masking): used the proper named import from hook-std to e…
travi Nov 21, 2022
8a0d8be
feat(node-versions): raised the minimum required node version to v18 …
travi Nov 21, 2022
d13ea92
style: prettier (#2624)
gr2m Nov 24, 2022
f32fd58
test(integration): updated the simulated environment to omit the `GIT…
travi Dec 2, 2022
71f45f9
test(integration): ran tests serially in hope of avoiding conflicts i…
travi Dec 2, 2022
62846a1
test(integration): omitted the `GITHUB_ACTION` env var as well
travi Dec 2, 2022
6051fae
Revert "test(integration): ran tests serially in hope of avoiding con…
travi Dec 2, 2022
c4cd639
Merge branch 'master' of github.com:semantic-release/semantic-release…
travi Dec 2, 2022
918eb59
fix(env-ci): updated to the stable esm-only version (#2632)
travi Dec 7, 2022
7365012
chore(overrides): removed the `overrides` definition (#2634)
travi Dec 7, 2022
eddbbb8
Merge branch 'master' of github.com:semantic-release/semantic-release…
travi Dec 9, 2022
ba05e08
docs(node-version): raised the minimum version to align with `engines…
travi Dec 11, 2022
0973513
Merge branch 'master' of github.com:semantic-release/semantic-release…
travi Dec 16, 2022
caa8b95
test(integration): used token auth for registry interactions rather t…
travi Dec 18, 2022
91bcb6b
Merge branch 'master' of github.com:semantic-release/semantic-release…
travi Jan 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/workflows/test.yml
Expand Up @@ -17,9 +17,8 @@ jobs:
strategy:
matrix:
node-version:
- 14.17
- 16.0.0
- 17
- 18.0.0
- 19

runs-on: ubuntu-latest

Expand All @@ -32,7 +31,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm clean-install
- name: Ensure dependencies are compatible with the version of node
run: npx ls-engines
- run: npm run test:ci

# separate job to set as required in branch protection,
Expand All @@ -44,9 +45,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: lts/*
cache: npm
- run: npm ci
- name: Ensure dependencies are compatible with the version of node
run: npx ls-engines@0.4
- run: npm clean-install
- run: npm run lint
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
17 changes: 16 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -3,6 +3,7 @@
✨ Thanks for contributing to **semantic-release**! ✨

As a contributor, here are the guidelines we would like you to follow:

- [Code of conduct](#code-of-conduct)
- [How can I contribute?](#how-can-i-contribute)
- [Using the issue tracker](#using-the-issue-tracker)
Expand Down Expand Up @@ -74,24 +75,31 @@ Here is a summary of the steps to follow:

1. [Set up the workspace](#set-up-the-workspace)
2. If you cloned a while ago, get the latest changes from upstream and update dependencies:

```bash
$ git checkout master
$ git pull upstream master
$ rm -rf node_modules
$ npm install
```

3. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix:

```bash
$ git checkout -b <topic-branch-name>
```

4. Make your code changes, following the [Coding rules](#coding-rules)
5. Push your topic branch up to your fork:

```bash
$ git push origin <topic-branch-name>
```

6. [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request) with a clear title and description.

**Tips**:

- For ambitious tasks, open a Pull Request as soon as possible with the `[WIP]` prefix in the title, in order to get feedback and help from the community.
- [Allow semantic-release maintainers to make changes to your Pull Request branch](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
This way, we can rebase it and make some minor changes if necessary.
Expand All @@ -102,6 +110,7 @@ $ git push origin <topic-branch-name>
### Source code

To ensure consistency and quality throughout the source code, all code modifications must have:

- No [linting](#lint) errors
- A [test](#tests) for every possible case introduced by your code change
- **100%** test coverage
Expand All @@ -112,6 +121,7 @@ To ensure consistency and quality throughout the source code, all code modificat
### Documentation

To ensure consistency and quality, all documentation modifications must:

- Refer to brand in [bold](https://help.github.com/articles/basic-writing-and-formatting-syntax/#styling-text) with proper capitalization, i.e. **GitHub**, **semantic-release**, **npm**
- Prefer [tables](https://help.github.com/articles/organizing-information-with-tables) over [lists](https://help.github.com/articles/basic-writing-and-formatting-syntax/#lists) when listing key values, i.e. List of options with their description
- Use [links](https://help.github.com/articles/basic-writing-and-formatting-syntax/#links) when you are referring to:
Expand All @@ -133,6 +143,7 @@ To ensure consistency and quality, all documentation modifications must:
#### Atomic commits

If possible, make [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit), which means:

- a commit should contain exactly one self-contained functional change
- a functional change should be contained in exactly one commit
- a commit should not create an inconsistent state (such as test errors, linting errors, partial fix, feature with documentation etc...)
Expand Down Expand Up @@ -166,7 +177,7 @@ In the body it should say: `This reverts commit <hash>.`, where the hash is the
The type must be one of the following:

| Type | Description |
|--------------|-------------------------------------------------------------------------------------------------------------|
| ------------ | ----------------------------------------------------------------------------------------------------------- |
| **build** | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
| **ci** | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) |
| **docs** | Documentation only changes |
Expand All @@ -186,10 +197,12 @@ The subject contains succinct description of the change:
- no dot (.) at the end

#### Body

Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

#### Footer

The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**.

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines.
Expand Down Expand Up @@ -240,6 +253,7 @@ Prettier formatting will be automatically verified and fixed by XO.
Before pushing your code changes make sure there are no linting errors with `npm run lint`.

**Tips**:

- Most linting errors can be automatically fixed with `npm run lint -- --fix`.
- Install the [XO plugin](https://github.com/sindresorhus/xo#editor-plugins) for your editor to see linting errors directly in your editor and automatically fix them on save.

Expand All @@ -256,6 +270,7 @@ $ npm run test
```

**Tips:** During development you can:

- run only a subset of test files with `ava <glob>`, for example `ava test/mytestfile.test.js`
- run in watch mode with `ava -w` to automatically run a test file when you modify it
- run only the test you are working on by adding [`.only` to the test definition](https://github.com/avajs/ava#running-specific-tests)
Expand Down
9 changes: 4 additions & 5 deletions README.md
Expand Up @@ -56,10 +56,10 @@ Tools such as [commitizen](https://github.com/commitizen/cz-cli) or [commitlint]

The table below shows which commit message gets you which release type when `semantic-release` runs (using the default configuration):

| Commit message | Release type |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- |
| `fix(pencil): stop graphite breaking when too much pressure applied` | ~~Patch~~ Fix Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| Commit message | Release type |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
| `fix(pencil): stop graphite breaking when too much pressure applied` | ~~Patch~~ Fix Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release <br /> (Note that the `BREAKING CHANGE: ` token must be in the footer of the commit) |

### Automation with CI
Expand Down Expand Up @@ -145,7 +145,6 @@ Let people know that your package is published using **semantic-release** and wh

```md
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)

```

## Team
Expand Down
5 changes: 5 additions & 0 deletions SUMMARY.md
@@ -1,6 +1,7 @@
# Summary

## Usage

- [Getting started](docs/usage/getting-started.md#getting-started)
- [Installation](docs/usage/installation.md#installation)
- [CI Configuration](docs/usage/ci-configuration.md#ci-configuration)
Expand All @@ -10,10 +11,12 @@
- [Shareable configurations](docs/usage/shareable-configurations.md)

## Extending

- [Plugins](docs/extending/plugins-list.md)
- [Shareable configuration](docs/extending/shareable-configurations-list.md)

## Recipes

- [CI configurations](docs/recipes/ci-configurations/README.md)
- [CircleCI 2.0](docs/recipes/ci-configurations/circleci-workflows.md)
- [Travis CI](docs/recipes/ci-configurations/travis.md)
Expand All @@ -28,11 +31,13 @@
- [Publishing pre-releases](docs/recipes/release-workflow/pre-releases.md)

## Developer guide

- [JavaScript API](docs/developer-guide/js-api.md)
- [Plugin development](docs/developer-guide/plugin.md)
- [Shareable configuration development](docs/developer-guide/shareable-configuration.md)

## Support

- [Resources](docs/support/resources.md)
- [Frequently Asked Questions](docs/support/FAQ.md)
- [Troubleshooting](docs/support/troubleshooting.md)
Expand Down
33 changes: 17 additions & 16 deletions bin/semantic-release.js
@@ -1,30 +1,32 @@
#!/usr/bin/env node

// Bad news: We have to write plain ES5 in this file
// Good news: It's the only file of the entire project

/* eslint-disable no-var */

var semver = require('semver');
var execa = require('execa');
var findVersions = require('find-versions');
var pkg = require('../package.json');
import semver from "semver";
import { execa } from "execa";
import findVersions from "find-versions";
import cli from "../cli.js";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const { engines } = require("../package.json");
const { satisfies, lt } = semver;

var MIN_GIT_VERSION = '2.7.1';
const MIN_GIT_VERSION = "2.7.1";

if (!semver.satisfies(process.version, pkg.engines.node)) {
if (!satisfies(process.version, engines.node)) {
console.error(
`[semantic-release]: node version ${pkg.engines.node} is required. Found ${process.version}.
`[semantic-release]: node version ${engines.node} is required. Found ${process.version}.

See https://github.com/semantic-release/semantic-release/blob/master/docs/support/node-version.md for more details and solutions.`
);
process.exit(1);
}

execa('git', ['--version'])
.then(({stdout}) => {
var gitVersion = findVersions(stdout)[0];
if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
execa("git", ["--version"])
.then(({ stdout }) => {
const gitVersion = findVersions(stdout)[0];
if (lt(gitVersion, MIN_GIT_VERSION)) {
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
process.exit(1);
}
Expand All @@ -35,8 +37,7 @@ execa('git', ['--version'])
process.exit(1);
});

// Node 10+ from this point on
require('../cli')()
cli()
.then((exitCode) => {
process.exitCode = exitCode;
})
Expand Down
64 changes: 32 additions & 32 deletions cli.js
@@ -1,62 +1,62 @@
const {argv, env, stderr} = require('process'); // eslint-disable-line node/prefer-global/process
const util = require('util');
const hideSensitive = require('./lib/hide-sensitive');
import util from "node:util";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import hideSensitive from "./lib/hide-sensitive.js";

const stringList = {
type: 'string',
type: "string",
array: true,
coerce: (values) =>
values.length === 1 && values[0].trim() === 'false'
values.length === 1 && values[0].trim() === "false"
? []
: values.reduce((values, value) => values.concat(value.split(',').map((value) => value.trim())), []),
: values.reduce((values, value) => values.concat(value.split(",").map((value) => value.trim())), []),
};

module.exports = async () => {
const cli = require('yargs')
.command('$0', 'Run automated package publishing', (yargs) => {
export default async () => {
const cli = yargs(hideBin(process.argv))
.command("$0", "Run automated package publishing", (yargs) => {
yargs.demandCommand(0, 0).usage(`Run automated package publishing

Usage:
semantic-release [options] [plugins]`);
})
.option('b', {alias: 'branches', describe: 'Git branches to release from', ...stringList, group: 'Options'})
.option('r', {alias: 'repository-url', describe: 'Git repository URL', type: 'string', group: 'Options'})
.option('t', {alias: 'tag-format', describe: 'Git tag format', type: 'string', group: 'Options'})
.option('p', {alias: 'plugins', describe: 'Plugins', ...stringList, group: 'Options'})
.option('e', {alias: 'extends', describe: 'Shareable configurations', ...stringList, group: 'Options'})
.option('ci', {describe: 'Toggle CI verifications', type: 'boolean', group: 'Options'})
.option('verify-conditions', {...stringList, group: 'Plugins'})
.option('analyze-commits', {type: 'string', group: 'Plugins'})
.option('verify-release', {...stringList, group: 'Plugins'})
.option('generate-notes', {...stringList, group: 'Plugins'})
.option('prepare', {...stringList, group: 'Plugins'})
.option('publish', {...stringList, group: 'Plugins'})
.option('success', {...stringList, group: 'Plugins'})
.option('fail', {...stringList, group: 'Plugins'})
.option('debug', {describe: 'Output debugging information', type: 'boolean', group: 'Options'})
.option('d', {alias: 'dry-run', describe: 'Skip publishing', type: 'boolean', group: 'Options'})
.option('h', {alias: 'help', group: 'Options'})
.option('v', {alias: 'version', group: 'Options'})
.option("b", { alias: "branches", describe: "Git branches to release from", ...stringList, group: "Options" })
.option("r", { alias: "repository-url", describe: "Git repository URL", type: "string", group: "Options" })
.option("t", { alias: "tag-format", describe: "Git tag format", type: "string", group: "Options" })
.option("p", { alias: "plugins", describe: "Plugins", ...stringList, group: "Options" })
.option("e", { alias: "extends", describe: "Shareable configurations", ...stringList, group: "Options" })
.option("ci", { describe: "Toggle CI verifications", type: "boolean", group: "Options" })
.option("verify-conditions", { ...stringList, group: "Plugins" })
.option("analyze-commits", { type: "string", group: "Plugins" })
.option("verify-release", { ...stringList, group: "Plugins" })
.option("generate-notes", { ...stringList, group: "Plugins" })
.option("prepare", { ...stringList, group: "Plugins" })
.option("publish", { ...stringList, group: "Plugins" })
.option("success", { ...stringList, group: "Plugins" })
.option("fail", { ...stringList, group: "Plugins" })
.option("debug", { describe: "Output debugging information", type: "boolean", group: "Options" })
.option("d", { alias: "dry-run", describe: "Skip publishing", type: "boolean", group: "Options" })
.option("h", { alias: "help", group: "Options" })
.strict(false)
.exitProcess(false);

try {
const {help, version, ...options} = cli.parse(argv.slice(2));
const { help, version, ...options } = cli.parse(process.argv.slice(2));

if (Boolean(help) || Boolean(version)) {
return 0;
}

if (options.debug) {
// Debug must be enabled before other requires in order to work
require('debug').enable('semantic-release:*');
(await import("debug")).default.enable("semantic-release:*");
}

await require('.')(options);
await (await import("./index.js")).default(options);
return 0;
} catch (error) {
if (error.name !== 'YError') {
stderr.write(hideSensitive(env)(util.inspect(error, {colors: true})));
if (error.name !== "YError") {
process.stderr.write(hideSensitive(process.env)(util.inspect(error, { colors: true })));
}

return 1;
Expand Down