Skip to content

Commit

Permalink
feat: replace standard-version with release-please.yml
Browse files Browse the repository at this point in the history
BREAKING CHANGE: replace `standard-version` with `release-please.yml`
  • Loading branch information
remarkablemark committed Sep 2, 2023
1 parent c511892 commit f2eaa64
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
15 changes: 15 additions & 0 deletions files/.github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: release-please
on:
push:
branches:
- master

jobs:
release-please:
runs-on: ubuntu-latest

steps:
- name: Release Please
uses: google-github-actions/release-please-action@v3
with:
release-type: node
21 changes: 19 additions & 2 deletions src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ exports[`CLI copies .commitlintrc.json 1`] = `
}
`;

exports[`CLI copies .github/workflows/release-please.yml 1`] = `
"name: release-please
on:
push:
branches:
- master
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- name: Release Please
uses: google-github-actions/release-please-action@v3
with:
release-type: node
"
`;

exports[`CLI updates package.json 1`] = `
{
"author": "",
Expand All @@ -26,7 +45,6 @@ exports[`CLI updates package.json 1`] = `
"@commitlint/config-conventional": "^17.7.0",
"husky": "^8.0.3",
"pinst": "^3.0.0",
"standard-version": "^9.5.0",
},
"keywords": [],
"license": "ISC",
Expand All @@ -36,7 +54,6 @@ exports[`CLI updates package.json 1`] = `
"postinstall": "husky install",
"postpublish": "pinst --enable",
"prepublishOnly": "pinst --disable",
"release": "standard-version --no-verify",
"test": "echo "Error: no test specified" && exit 1",
},
"version": "1.0.0",
Expand Down
6 changes: 6 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ describe('CLI', () => {
expect(JSON.parse(readFileSync('.commitlintrc.json'))).toMatchSnapshot();
});

it('copies .github/workflows/release-please.yml', () => {
expect(
readFileSync('.github/workflows/release-please.yml'),
).toMatchSnapshot();
});

it('adds .husky/.commit-msg', () => {
expect(readFileSync('.husky/commit-msg')).toMatchSnapshot();
});
Expand Down
19 changes: 4 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,20 @@ const devDependencies = [
'@commitlint/cli',
'@commitlint/config-conventional',
'husky',
'standard-version',
];

/**
* Update `package.json`.
*/
const packageJson = require(packageJsonPath);
packageJson.scripts = packageJson.scripts || {};
const { postinstall, release } = packageJson.scripts;
const { postinstall } = packageJson.scripts;

const huskyInstall = 'husky install';
packageJson.scripts.postinstall = postinstall
? `${huskyInstall} && ${postinstall}`
: huskyInstall;

const standardVersion = 'standard-version --no-verify';
packageJson.scripts.release = release
? `${standardVersion} && ${release}`
: standardVersion;

if (!packageJson.private) {
devDependencies.push('pinst');
const { postpublish, prepublishOnly } = packageJson.scripts;
Expand Down Expand Up @@ -109,14 +103,9 @@ isGit && exec('git add package.json');
* Copy files.
*/
log('Copying files...');
const filesPath = path.resolve(__dirname, '../files');
fs.readdirSync(filesPath).forEach((filename: string) => {
const source = path.resolve(filesPath, filename);
const destination = path.resolve(cwd, filename);
log(`Copying \`${filename}\``);
fs.copyFileSync(source, destination);
isGit && exec(`git add ${filename}`);
});
fs.cpSync(path.resolve(__dirname, '../files'), cwd, { recursive: true });
isGit &&
exec(`git add .commitlintrc.json .github/workflows/release-please.yml`);

/**
* Add hooks.
Expand Down

0 comments on commit f2eaa64

Please sign in to comment.